-
Notifications
You must be signed in to change notification settings - Fork 205
/
build.gradle
290 lines (257 loc) · 7.96 KB
/
build.gradle
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
import java.security.MessageDigest
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
configurations {
provided
compile
}
apply plugin: 'java'
apply plugin: 'maven-publish'
repositories {
flatDir { dirs uri("${projectDir}/lib") }
maven {
url 'https://mvn.freenetproject.org'
metadataSources {
artifact()
}
}
mavenCentral()
}
sourceSets {
main.compileClasspath += configurations.provided
test.compileClasspath += configurations.provided
}
def version_buildir = file("$projectDir/build/tmp/compileVersion/")
def version_src = 'freenet/node/Version.java'
sourceSets {
main {
java {
srcDir 'src/'
}
}
test {
java {
srcDir 'test/'
}
}
}
def gitrev
task buildInfo {
try {
def cmd = "git describe --always --abbrev=4 --dirty"
def proc = cmd.execute()
gitrev = proc.text.trim()
} catch (IOException ignored) {
gitrev = "@unknown@"
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(Javadoc) {
options.encoding = "UTF-8"
}
task compileVersion (type: JavaCompile) {
copy {
from sourceSets.main.java.srcDirs
into version_buildir
include "${version_src}"
filter {
String line -> line.replaceAll("@custom@","${gitrev}")
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
source = version_buildir
include "${version_src}"
classpath = files(sourceSets.main.compileClasspath, sourceSets.main.output.classesDirs)
destinationDirectory.set(layout.buildDirectory.dir("java/version/").get())
}
compileVersion.dependsOn buildInfo
compileVersion.dependsOn compileJava
//processResources.dependsOn compileVersion
task jar (type: Jar, overwrite: true) {
from (compileVersion) {
include 'freenet/node/Version**class'
}
from ("${buildDir}/classes/java/main/") {
exclude 'freenet/node/Version.class'
exclude 'freenet/node/Version$1.class'
}
preserveFileTimestamps = true
reproducibleFileOrder = true
duplicatesStrategy = "warn"
archivesBaseName = "freenet"
manifest {
attributes("Permissions": "all-permissions")
attributes("Application-Name": "Freenet REference Daemon")
attributes("Required-Ext-Version": 29)
attributes("Recommended-Ext-Version": 29)
attributes("Compiled-With": "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})")
attributes([
"Specification-Title": "Freenet",
"Specification-Version": "0.7.5",
"Specification-Vendor": "freenetproject.org",
"Implementation-Title": "Freenet",
"Implementation-Version": "0.7.5 ${gitrev}",
"Implementation-Vendor": "freenetproject.org",
], "common")
}
}
jar.dependsOn processResources
def jars = []
gradle.addListener(new TaskExecutionListener() {
void afterExecute(Task task, TaskState state) {
if(task in AbstractArchiveTask) {
jars << task.outputs.files.singleFile
}
}
void beforeExecute(Task task) { }
})
gradle.addBuildListener(new BuildAdapter() {
void buildFinished(BuildResult result) {
if(jars) {
def hash = {
File file -> def sha256 = MessageDigest.getInstance('SHA-256')
file.eachByte(1024 * 4) { buffer, len -> sha256.update(buffer, 0, len) }
println "SHA-256 of ${file.name}: ${sha256.digest().encodeHex().toString()}"
}
jars.each { hash(it) }
}
}
})
task copyResourcesToClasses2 {
inputs.files sourceSets.main.allSource
outputs.dir layout.buildDirectory.dir("classes/java/main/")
doLast {
copy {
from sourceSets.main.allSource
into layout.buildDirectory.dir("classes/java/main/")
include 'freenet/l10n/*properties'
include 'freenet/l10n/iso-*.tab'
include 'freenet/clients/http/staticfiles/**'
include 'freenet/clients/http/templates/**'
include '../dependencies.properties'
}
copy {
from "${projectDir}/"
into layout.buildDirectory.dir("classes/java/main/")
include 'dependencies.properties'
}
}
}
processResources.dependsOn copyResourcesToClasses2
task copyTestResourcesToClasses2 {
inputs.files sourceSets.test.allSource
outputs.dir layout.buildDirectory.dir("classes/java/test/")
doLast {
copy {
from sourceSets.test.allSource
into layout.buildDirectory.dir("classes/java/test/")
include 'freenet/client/filter/*/**'
include 'freenet/crypt/ciphers/rijndael-gladman-test-data/**'
include 'freenet/l10n/*properties'
include 'freenet/clients/http/templates/**'
}
}
}
compileTestJava.dependsOn copyResourcesToClasses2
compileTestJava.dependsOn copyTestResourcesToClasses2
test {
if(JavaVersion.current() >= JavaVersion.VERSION_1_9) {
jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED'
jvmArgs '--add-opens=java.base/java.util=ALL-UNNAMED'
jvmArgs '--add-opens=java.base/java.io=ALL-UNNAMED'
jvmArgs '--add-opens=java.base/java.util.zip=ALL-UNNAMED'
}
minHeapSize = "128m"
maxHeapSize = "512m"
// no inner class
include 'freenet/**/*Test.class'
exclude 'freenet/**/*$*Test.class'
workingDir = layout.buildDirectory.dir("classes/java/test/")
scanForTestClasses = false
systemProperties += [
"test.l10npath_test": "freenet/l10n/",
"test.l10npath_main": "../main/freenet/l10n/"
// "test.extensive":
// "test.verbose":
// "test.benchmark":
]
}
tasks.withType(Test) {
enableAssertions = false
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'org.freenetproject'
artifactId "fred"
version gitrev
from components.java
}
}
repositories {
maven {
url "s3://mvn.freenetproject.org/"
credentials(AwsCredentials) {
accessKey System.getenv('AWS_ACCESS_KEY_ID')
secretKey System.getenv('AWS_SECRET_ACCESS_KEY')
}
}
}
}
task copyRuntimeLibs(type: Copy) {
into "${buildDir}/output/"
from configurations.runtimeClasspath
from jar
}
copyRuntimeLibs.dependsOn jar
// In this section you declare the dependencies for your production and test code
dependencies {
implementation "org.bouncycastle:bcprov-jdk15on:1.59"
implementation "net.java.dev.jna:jna:4.5.2"
implementation "net.java.dev.jna:jna-platform:4.5.2"
implementation "org.freenetproject:freenet-ext:29"
implementation "io.pebbletemplates:pebble:3.1.5"
// dependencies of pebble
implementation "org.unbescape:unbescape:1.1.6.RELEASE"
implementation "org.slf4j:slf4j-api:1.7.25"
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:1.9.5"
testImplementation "org.hamcrest:hamcrest-library:1.3"
testImplementation "org.hamcrest:hamcrest-core:1.3"
testImplementation "org.objenesis:objenesis:1.0"
}
task tar(type: Tar) {
description = "Build a source release, specifically excluding the build directories and gradle wrapper files"
compression = Compression.BZIP2
baseName = "freenet-sources"
from(project.rootDir) {
exclude '**/build'
exclude 'build'
exclude '.gradle'
}
into(baseName)
preserveFileTimestamps = true
reproducibleFileOrder = true
// Set destination directory.
destinationDir = file("${project.buildDir}")
archiveName = "${baseName}.tgz"
doLast { // generate md5 checksum
ant.checksum file:"$destinationDir/$archiveName"
}
}
javadoc {
doLast {
failOnError false
}
}