@ -6,6 +6,7 @@ buildscript {
plugins {
id 'java'
id 'distribution'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '5.1.0'
}
@ -71,7 +72,9 @@ tasks.withType(JavaCompile) {
}
dependencies {
implementation project ( 'libbuild:J7Zip-modified' ) // support library in libbuild
// implementation project ( 'libbuild:J7Zip-modified' ) // support library in libbuild ( fyi: downside groovy / gradle use internal * . class instead of * . jar = trouble in task packageDist )
// implementation 'net.yacy.extlib:J7Zip-modified:1.02' // alternatively support library from mavenLocal ( ) repo ( use publishToMavenLocal in subproject first )
implementation fileTree ( dir: 'lib' , include: 'J7Zip-modified.jar' ) // switched back to use local lib /jar for this one library (avoiding sub-project execution w/ o need )
implementation 'org.apache.james:apache-mime4j:0.6'
implementation 'org.apache.calcite.avatica:avatica-core:1.13.0'
@ -216,7 +219,7 @@ task runGitComInf(type: JavaExec) {
// prepare yacyBuildProperties . java from template ( needed after commits or new versions )
// read values from property file generated by GitComInf tool
import org.apache.tools.ant.filters.ReplaceTokens
task prepYaCyProperties ( type: Copy ) {
task prepYaCyProperties ( type: Copy , dependsOn : [ 'runGitComInf' ] ) {
mustRunAfter runGitComInf
def propfile = "build/tmp/gitbuildnumber.properties" ;
if ( project . file ( propfile ) . exists ( ) ) { // must check otherwise any action may stop after clean on this error
@ -239,12 +242,11 @@ task prepYaCyProperties (type: Copy) {
filter ( ReplaceTokens , tokens: [ REPL_VERSION: version , REPL_PKGMANAGER: "false" , REPL_RESTARTCMD: "/etc/init.d/yacy restart" ] ) // gradle . project . version + some defaults from ant
}
}
prepYaCyProperties . dependsOn ( runGitComInf )
compileJava . dependsOn ( prepYaCyProperties ) // must be executed before compile
compileJava . dependsOn ( prepYaCyProperties ) // must be executed before compile ( due to source template filtering )
// implement ant task to simulate old Ant build for htroot ,
// to avoid import of complete build . xml ( as currently used )
task compileHtrootServlets {
task compileHtrootServlets ( dependsOn: [ 'jar' ] ) {
ant {
path ( id: 'project.class.path' ) {
@ -254,7 +256,7 @@ task compileHtrootServlets {
configurations . compileClasspath . each { pathelement ( location: it ) }
}
javac ( srcdir: 'htroot' , excludes: 'processing/**' ,
source: '1.8' , target: '1.8' ,
source: java . sourceCompatibility , target: java . targetCompatibility ,
debug: "true" , debuglevel: "lines,vars,source" , includeantruntime: "false" , encoding: "UTF-8" ) {
classpath ( refid: 'project.class.path' )
}
@ -262,3 +264,164 @@ task compileHtrootServlets {
}
startScripts . dependsOn ( compileHtrootServlets )
// copy additional files into directory used to create distribution archive ( distZip / distTar )
task copyFilesToDistDir ( dependsOn : [ 'compileJava' , 'jar' , 'compileHtrootServlets' ] ) {
String instDir = "$buildDir/RELEASE/MAIN/"
outputs . files fileTree ( instDir )
copy {
from 'addon'
into instDir + "addon"
}
copy {
from 'bin'
into instDir + "bin"
}
copy {
from 'defaults'
into instDir + "defaults"
}
copy {
from 'dictionaries'
into instDir + "dictionaries"
}
copy {
from 'examples'
into instDir + "examples"
}
copy {
from 'htroot'
into instDir + "htroot"
}
copy {
from 'langdetect'
into instDir + "langdetect"
}
copy {
from 'lib'
include '*.License'
into instDir + "lib"
}
copy {
from 'libbuild'
exclude '**/build/**'
exclude '**/target/**'
into instDir + "libbuild"
}
copy {
from 'locales'
into instDir + "locales"
}
copy {
from 'skins'
into instDir + "skins"
}
copy {
from 'source'
into instDir + "source"
}
copy {
from 'vocabularies'
into instDir + "vocabularies"
}
copy {
from new File ( '.' )
include '*.bat'
include '*.sh'
include 'gradlew'
include 'AUTHORS'
include 'COPYRIGHT'
include 'NOTICE'
include 'readme.txt'
include 'ChangeLog'
include 'gpl.txt'
include 'yacy.yellow'
include '*.properties'
include 'build.gradle'
include 'settings.gradle'
include 'build.xml'
into instDir
}
}
distZip . dependsOn ( copyFilesToDistDir )
distTar . dependsOn ( copyFilesToDistDir )
// declare distribution source directory to be added to archives
distributions {
main {
// Gradle appends always the version to the BaseName so this doesn ' t work ,
// legacy archive name must be archieved by file rename
//
// String Dst = project . ext . filterTokens . get ( 'DSTAMP' )
// String rNr = project . ext . filterTokens . get ( 'releaseNr' )
// String branch = project . ext . filterTokens . get ( 'branch' )
//
// distributionBaseName = 'yacy' + branch + '_v' + version + '_' + Dst + '_' + rNr
contents { // fyi: content completed by copyFilesToDistDir
from 'build/RELEASE/MAIN'
}
}
}
// copy runtime dependencies ( jar ) to the distribution directory
task copyDependenciesForDistribution {
// do a late copy of dependencies to dist lib directory to not interfere with standard distZip
// which includes the lib ( and bin ) directory by default
// actually if copied early ( e . g . task copyFilesToDistDir ) final Gradle zip / tar archive has all files double in lib dir ( believe it or not )
String instDir = "$buildDir/RELEASE/MAIN/"
copy { // needed for legacy distribution file ( task packageDist ) - ( fyi: gradle . distXxx includes it autom . in dist archive )
def destination = project . file ( instDir + "lib" )
from configurations . compileClasspath
eachFile { // prevent overwriting existing files
if ( it . getRelativePath ( ) . getFile ( destination ) . exists ( ) ) {
it . exclude ( )
}
}
into instDir + "lib"
}
copy {
from 'lib'
include 'yacycore.jar'
into instDir + "lib"
}
}
// create a legacy distribution zip archive
task packageDistZip ( type : Zip , dependsOn : [ 'copyDependenciesForDistribution' , 'copyFilesToDistDir' , 'prepYaCyProperties' ] ) {
String Dst = project . ext . filterTokens . get ( 'DSTAMP' )
String rNr = project . ext . filterTokens . get ( 'releaseNr' )
String branch = project . ext . filterTokens . get ( 'branch' )
String destName = 'yacy' + branch + '_v' + version + '_' + Dst + '_' + rNr + '.' + archiveExtension . get ( )
archiveFileName = destName
destinationDirectory = layout . buildDirectory . dir ( 'distributions' )
from layout . buildDirectory . dir ( "RELEASE/MAIN" )
into 'yacy'
}
// create a legacy distribution gz / tar archive
task packageDistTar ( type : Tar , dependsOn : [ 'copyDependenciesForDistribution' , 'copyFilesToDistDir' , 'prepYaCyProperties' ] ) {
compression 'GZIP'
String Dst = project . ext . filterTokens . get ( 'DSTAMP' )
String rNr = project . ext . filterTokens . get ( 'releaseNr' )
String branch = project . ext . filterTokens . get ( 'branch' )
String destName = 'yacy' + branch + '_v' + version + '_' + Dst + '_' + rNr + '.tar.gz' // ! Gradle would use ext . tgz ( archiveExtension . get ( ) )
archiveFileName = destName
destinationDirectory = layout . buildDirectory . dir ( 'distributions' )
from layout . buildDirectory . dir ( "RELEASE/MAIN" )
into 'yacy'
}
// wrapper to create legacy distribution archives
task packageDist ( dependsOn : [ 'copyDependenciesForDistribution' , 'packageDistZip' , 'packageDistTar' ] ) {
// do a late copy of dependencies to dist lib directory to not interfere with standard distZip
// which includes the lib ( and bin ) directory by default ( task copyDependenciesForDistribution )
// actually if copied early ( e . g . in task copyFilesToDistDir ) final Gradle zip / tar archive has all files double in lib dir ( believe it or not )
}