1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
buildscript {
dependencies {
classpath "org.mini2Dx:parcl:1.8.0"
}
}
plugins {
id 'java'
id 'distribution'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.2' // uberJar plugin
id 'com.github.langmo.gradlensis' version '0.1.0' // NSIS plugin
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: "org.mini2Dx.parcl"
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDirs = ['source']
}
}
test {
java {
srcDirs = ['test/java']
}
}
htroot { // optional sourceset to have htroot servelets available/visible in development IDE
java {
srcDirs = ['htroot']
exclude 'processing/**'
compileClasspath = configurations.compileClasspath + jar.outputs.files
}
}
}
group = 'net.yacy'
version = '1.925'
description = 'YaCy Search Server'
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
mainClassName = "net.yacy.yacy"
applicationDefaultJvmArgs = ["-Xmx1024m"]
// create property store for filterTokens (here, to make sure it exist)
project.ext.filterTokens = new Properties()
parcl {
exe {
exeName = "YaCy"
}
app {
vmArgs = ["-Xmx1g"]
appName = "YaCy"
icon = "addon/YaCy.icns"
applicationCategory = "Search-Engine"
displayName = 'YaCy Search Engine'
identifier = 'net.yacy'
copyright = 'Copyright 2021 Michael Peter Christen et al.'
zipName = 'YaCy.zip'
}
linux {
binName = "YaCy"
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
dependencies {
// used by YaCy code
// 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 group: 'org.bouncycastle', name: 'bcmail-jdk15on', version: '1.69'
implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.21'
implementation group: 'commons-fileupload', name: 'commons-fileupload', version: '1.4'
implementation group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
implementation group: 'com.hazelcast', name: 'hazelcast', version: '4.2'
implementation group: 'com.ibm.icu', name: 'icu4j', version: '63.1'
implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-bmp', version: '3.3.2'
implementation group: 'com.twelvemonkeys.imageio', name: 'imageio-tiff',version: '3.3.2'
implementation group: 'net.jthink', name: 'jaudiotagger', version: '2.2.5'
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
implementation group: 'net.sourceforge.jchardet', name: 'jchardet', version: '1.0'
implementation group: 'jcifs', name: 'jcifs', version: '1.3.17'
implementation group: 'org.eclipse.jetty', name: 'jetty-http', version: '9.4.35.v20201120'
implementation group: 'org.eclipse.jetty', name: 'jetty-proxy', version: '9.4.35.v20201120'
implementation group: 'org.eclipse.jetty', name: 'jetty-security', version: '9.4.35.v20201120'
implementation group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.4.35.v20201120'
implementation group: 'org.eclipse.jetty', name: 'jetty-servlets', version: '9.4.35.v20201120'
implementation group: 'org.eclipse.jetty', name: 'jetty-util', version: '9.4.35.v20201120'
implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.35.v20201120'
implementation group: 'com.jcraft', name: 'jsch', version: '0.1.54'
implementation group: 'com.googlecode.json-simple',name: 'json-simple', version: '1.1.1'
implementation group: 'org.jsoup', name: 'jsoup', version: '1.14.3'
implementation group: 'org.jwat', name: 'jwat-warc', version: '1.1.1'
implementation group: 'com.cybozu.labs', name: 'langdetect', version: '1.1-20120112'
implementation group: 'com.drewnoakes', name: 'metadata-extractor', version: '2.11.0'
implementation group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.25'
implementation group: 'org.apache.poi', name: 'poi', version: '3.17'
implementation group: 'org.apache.poi', name: 'poi-scratchpad', version: '3.17'
implementation group: 'org.apache.solr', name: 'solr-core', version: '8.8.1'
implementation group: 'org.apache.solr', name: 'solr-solrj', version: '8.8.1'
implementation group: 'org.bitlet', name: 'weupnp', version: '0.1.4'
// overwrite version for transient dependencies
implementation 'org.eclipse.jetty:jetty-client:9.4.35.v20201120' // for solrj
implementation 'org.tukaani:xz:1.9' // commons.compress.compressors.xz uses this, but declares it as optional dependency
testImplementation 'junit:junit:4.13.2'
}
// exclude some unused/not needed automatic dependency imports
configurations.implementation {
exclude group: 'com.google.code.findbugs', module: 'jsr305'
exclude group: 'org.eclipse.jetty', module: 'jetty-alpn-client'
exclude group: 'org.eclipse.jetty', module: 'jetty-alpn-java-client'
exclude group: 'org.eclipse.jetty', module: 'jetty-alpn-java-server'
exclude group: 'org.eclipse.jetty', module: 'jetty-alpn-server'
// warning 'Class path contains multiple SLF4J bindings'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
// output to lib/yacycore.jar (like with ant with downside by determine class-path)
jar {
archiveFileName = 'yacycore.jar'
destinationDirectory = new File('lib')
manifest {
attributes(
"Main-Class": mainClassName ,
"Class-Path": configurations.runtimeClasspath.collect { it.name }.join(' ')
)
}
}
shadowJar.zip64 = true // saw build error: Execution failed for task ':shadowJar'. shadow.org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries.
// 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) {
def propfile = "gitbuildnumber.properties";
if (project.file(propfile).exists()) { // must check otherwise any action may stop after clean on this error
file("gitbuildnumber.properties").withReader {
Properties props = new Properties()
props.load(it)
project.ext.filterTokens.putAll(props)
}
} else { // on missing properties file use generic data
logger.error("prepYaCyProperties: file " + propfile + " is missing, you should re-run runGitComInf")
Properties props = new Properties()
String Dstr = new Date().format("yyyyMMDD")
String Tstr = new Date().format("yyyyMMDD-HHmmss")
props.put("branch","-dev")
props.put ("REPL_DATE",Dstr)
props.put ("REPL_REVISION_NR",Tstr)
project.ext.filterTokens.putAll(props)
}
String fdirname = sourceSets.main.java.srcDirs[0].name + '/net/yacy/peers/operation'
from fdirname
include('yacyBuildProperties.java.template')
rename 'yacyBuildProperties.java.template', 'yacyBuildProperties.java'
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.ext.filterTokens)
filter(ReplaceTokens, tokens: [REPL_VERSION: version, REPL_PKGMANAGER:"false", REPL_RESTARTCMD: "/etc/init.d/yacy restart"]) // gradle.project.version + some defaults from ant
into (fdirname)
}
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 (dependsOn: ['jar']) {
if (file('lib/yacycore.jar').exists()) { // prevent buildscript failing on prime build with fresh git clone due to javac error during gradle init
ant {
path(id:'project.class.path') {
// place yacycore.jar on classpath (not automatically done)
pathelement (location: jar.archiveFile.get())
// construct path elements
configurations.compileClasspath.each { pathelement (location: it) }
}
javac (srcdir:'htroot', excludes:'processing/**',
source:java.sourceCompatibility, target:java.targetCompatibility,
debug:"true", debuglevel:"lines,vars,source", includeantruntime:"false", encoding:"UTF-8") {
classpath (refid:'project.class.path')
}
}
}
}
// copy additional files into directory used to create distribution archive (distZip/distTar)
task copyFilesToDistDir (type: Copy, dependsOn : ['compileJava', 'jar', 'compileHtrootServlets']) {
String instDir = "$buildDir/RELEASE/MAIN/"
outputs.files fileTree(instDir)
from projectDir
include 'addon/**'
include 'bin/**'
include 'defaults/**'
include 'dictionaries/**'
include 'examples/**'
include 'gradle/**'
include 'htroot/**'
include 'langdetect/**'
include 'lib/**'
include 'libbuild/**'
include 'locales/**'
include 'skins/**'
include 'source/**'
include 'vocabularies/**'
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'
exclude '**/build/**'
exclude '**/target/**'
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('REPL_DATE')
// String rNr = project.ext.filterTokens.get('REPL_REVISION_NR')
// String branch = project.ext.filterTokens.get('branch')
//
// distributionBaseName = 'yacy' + branch + '_v' + version + '_' + Dst + '_' + rNr
contents { // fyi: content completed by copyFilesToDistDir
from 'build/RELEASE/MAIN'
exclude 'lib/*.jar'
// define unix/linux file permission
fileMode 0644
dirMode 0755
eachFile { file ->
if(file.getName().endsWith(".sh")) {
file.setMode(0755)
}
}
}
}
}
// configure distTar archive name
tasks.findByName('assembleDist').dependsOn('prepYaCyProperties') // make sure poperties are loaded before distTar/distZip
distTar {
compression 'GZIP'
archiveExtension = 'tar.gz'
String Dst = project.ext.filterTokens.get('REPL_DATE')
String rNr = project.ext.filterTokens.get('REPL_REVISION_NR')
String branch = project.ext.filterTokens.get('branch')
archiveVersion = '' // important as otherwise version is added automatically again to the end of archiveBaseName
archiveBaseName = 'yacy' + branch + '_v' + project.version + '_' + Dst + '_' + rNr // important to use project.version otherwise depreciated distZip.version is used (wich is now '')
}
// configure distZip archive name
distZip {
String Dst = project.ext.filterTokens.get('REPL_DATE')
String rNr = project.ext.filterTokens.get('REPL_REVISION_NR')
String branch = project.ext.filterTokens.get('branch')
archiveVersion = '' // important as otherwise version is added automatically again to the end of archiveBaseName
archiveBaseName = 'yacy' + branch + '_v' + project.version + '_' + Dst + '_' + rNr // important to use project.version otherwise depreciated distZip.version is used (wich is now '')
}
// 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)
from configurations.runtimeClasspath
into instDir + "lib"
}
copy { // add own jar (not included automatically)
from jar.outputs.files
into instDir + "lib"
}
}
// create a legacy distribution zip archive
task packageDistZip (type : Zip, dependsOn : ['copyDependenciesForDistribution','copyFilesToDistDir','prepYaCyProperties'] ) {
String Dst = project.ext.filterTokens.get('REPL_DATE')
String rNr = project.ext.filterTokens.get('REPL_REVISION_NR')
String branch = project.ext.filterTokens.get('branch')
String destName = 'yacy' + branch + '_v' + version + '_' + Dst + '_' + rNr + '.' + archiveExtension.get()
archiveFileName = destName
destinationDirectory = layout.buildDirectory.dir('distributions/legacyDistFiles')
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('REPL_DATE')
String rNr = project.ext.filterTokens.get('REPL_REVISION_NR')
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/legacyDistFiles')
from layout.buildDirectory.dir("RELEASE/MAIN")
fileMode 0644
eachFile { file ->
if(file.getName().endsWith(".sh")) {
file.setMode(0755)
}
}
into 'yacy'
}
// wrapper to create legacy distribution archives
task packageDist (dependsOn : ['copyDependenciesForDistribution','packageDistZip','packageDistTar'],group:'distribution') {
description 'Create legacy distribution tar.gz and zip archives'
// 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)
}
// configure Javadoc task
tasks.withType (Javadoc) {
destinationDir project.file("javadoc")
title = "YaCy " + version + " API Documentation"
failOnError = false
options.addStringOption("encoding","UTF-8" ) // or any reason to keep the old "iso-8859-1" ?
classpath = configurations.compileClasspath
includes = ['**/*.java']
}
// some legacy stuff packaged in separate archive
// archive in build/distributions
task packagePortalsearch (group:'distribution') {
description 'Bundles the javascript portalsearch as *.tar.gz distribution'
ant {
tar(destfile:'build/distributions/yacy-portalsearch.tar.gz', compression:'gzip', defaultexcludes:'yes', longfile:'fail') {
tarfileset (dir:'htroot/portalsearch/', prefix:'yacy/portalsearch/') {
include(name:'**/*')
}
tarfileset (dir:'htroot/jquery/', prefix:'yacy/jquery/') {
include(name:'**/*')
}
tarfileset (dir:"htroot/yacy/ui/img-2", prefix:'yacy/ui/img-2/') {
include(name:"magnify.png")
include(name:"cancel_round.png")
include(name:"stop.png")
}
}
}
}
// Configuration of gradle-nsis plugin.
nsis {
// path to the NSIS configuration file
configuration = file("${buildDir}/RELEASE/WINDOWS/build.nsi")
// folder where the NSIS installer generator is run. All paths
// in the NSIS configuration file are relative to this folder.
runIn = file("${buildDir}")
}
// prepare the NSIS build script
task prepNsis (type: Copy, dependsOn: ['prepYaCyProperties']) {
from projectDir
include 'build.nsi'
include 'gpl.txt'
into 'build/RELEASE/WINDOWS'
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.ext.filterTokens)
filter(ReplaceTokens, tokens: [REPL_VERSION: version])
copy {
from projectDir
include 'gpl.txt'
into buildDir
}
}
// wrapper to run prepNsis task before nsis createInstaller, to copy some config files
task distWinInstaller (dependsOn:['copyFilesToDistDir','copyDependenciesForDistribution','prepNsis','createInstaller'], group:'distribution') {
description 'Creates a Win installer distribution exe file'
tasks.findByName('createInstaller').mustRunAfter 'prepNsis'
}
// runs the support tool which creates gitbuildnumber.properties from info of local git repository
task storeGitComInf(type: JavaExec) {
mustRunAfter(build)
classpath = files('libbuild/GitComInf-all.jar')
args = [project.projectDir.getPath(), project.projectDir.getPath() + "/gitbuildnumber.properties"]
mainClass = 'GitComInf'
}
//--- build aliases : define a synonym here if you want a shortcut to run multiple targets
// workaround to run storeGitComInf after a build without adding arbitray dependencies
// this makes sure gitbuildnumber.properties is availabel and up-to-date
def buildAliases = [
'build' : ['build','storeGitComInf']
]
def expandedTaskList = []
gradle.startParameter.taskNames.each {
expandedTaskList << (buildAliases[it] ? buildAliases[it] : it)
}
gradle.startParameter.taskNames = expandedTaskList.flatten()
|