This repository has been archived by the owner on Apr 24, 2021. It is now read-only.
forked from hyphanet/fred
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
274 lines (245 loc) · 8.04 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath files('gradle/gradle-witness.jar')
}
}
configurations {
provided
compile
}
apply plugin: 'witness'
apply plugin: 'java'
apply plugin: 'maven-publish'
repositories {
mavenLocal() // TODO: use lib/ instead?
maven { url 'https://mvn.freenetproject.org' }
jcenter()
}
sourceSets {
main.compileClasspath += configurations.provided
test.compileClasspath += configurations.provided
}
def version_buildir = "$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 (java.io.IOException e) {
gitrev = "@unknown@"
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.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.classesDir)
destinationDir = file("${buildDir}/java/version/")
}
compileVersion.dependsOn buildInfo
compileVersion.dependsOn compileJava
processResources.dependsOn compileVersion
task jar (type: Jar, overwrite: true) {
from (compileVersion) {
include 'freenet/node/Version**class'
preserveFileTimestamps = false
reproducibleFileOrder = true
}
from ("${buildDir}/classes/java/main/") {
exclude 'freenet/node/Version.class'
exclude 'freenet/node/Version$1.class'
preserveFileTimestamps = false
reproducibleFileOrder = true
}
duplicatesStrategy = "exclude"
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 = java.security.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.dir sourceSets.main.java.srcDirs
outputs.dir sourceSets.main.output.classesDir
doLast {
copy {
from sourceSets.main.java.srcDirs
into sourceSets.main.output.classesDir
include 'freenet/l10n/*properties'
include 'freenet/l10n/iso-*.tab'
include 'freenet/clients/http/staticfiles/**'
include '../dependencies.properties'
}
copy {
from "${projectDir}/"
into sourceSets.main.output.classesDir
include 'dependencies.properties'
}
}
}
processResources.dependsOn copyResourcesToClasses2
task copyTestResourcesToClasses2 {
inputs.dir sourceSets.test.java.srcDirs
outputs.dir sourceSets.test.output.classesDir
doLast {
copy {
from sourceSets.test.java.srcDirs
into sourceSets.test.output.classesDir
include 'freenet/client/filter/*/**'
include 'freenet/crypt/ciphers/rijndael-gladman-test-data/**'
include 'freenet/l10n/*properties'
}
}
}
compileTestJava.dependsOn copyResourcesToClasses2
compileTestJava.dependsOn copyTestResourcesToClasses2
test {
minHeapSize = "128m"
maxHeapSize = "512m"
// no inner class
include 'freenet/**/*Test.class'
exclude 'freenet/**/*$*Test.class'
workingDir = sourceSets.test.output.classesDir
scanForTestClasses = false
systemProperties += [
"test.l10npath_test": "freenet/l10n/",
"test.l10npath_main": "../main/freenet/l10n/"
// "test.extensive":
// "test.verbose":
// "test.benchmark":
]
}
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.runtime
from jar
}
copyRuntimeLibs.dependsOn jar
// In this section you declare the dependencies for your production and test code
dependencies {
compile "org.bouncycastle:bcprov-jdk15on:1.59"
compile "net.java.dev.jna:jna:4.5.2"
compile "net.java.dev.jna:jna-platform:4.5.2"
compile "org.freenetproject:freenet-ext:29"
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile "org.hamcrest:hamcrest-library:1.3"
}
dependencyVerification {
// testCompile includes all of compile deps... so let's include only these
includedConfigurations = [configurations.testCompile]
verify = [
'org.bouncycastle:bcprov-jdk15on:1c31e44e331d25e46d293b3e8ee2d07028a67db011e74cb2443285aed1d59c85',
'net.java.dev.jna:jna-platform:f1d00c167d8921c6e23c626ef9f1c3ae0be473c95c68ffa012bc7ae55a87e2d6',
'net.java.dev.jna:jna:0c8eb7acf67261656d79005191debaba3b6bf5dd60a43735a245429381dbecff',
'org.freenetproject:freenet-ext:32f2b3d6beedf54137ea2f9a3ebef67666d769f0966b08cd17fd7db59ba4d79f',
'junit:junit:59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a',
'org.mockito:mockito-core:f97483ba0944b9fa133aa29638764ddbeadb51ec3dbc02074c58fa2caecd07fa',
'org.hamcrest:hamcrest-library:711d64522f9ec410983bd310934296da134be4254a125080a0416ec178dfad1c',
'org.hamcrest:hamcrest-core:66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9',
'org.objenesis:objenesis:c5694b55d92527479382f254199b3c6b1d8780f652ad61e9ca59919887f491a8',
]
}
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 = false
reproducibleFileOrder = true
// Set destination directory.
destinationDir = file("${project.buildDir}")
archiveName = "${baseName}.tgz"
doLast { // generate md5 checksum
ant.checksum file:"$destinationDir/$archiveName"
}
}
javadoc << {
failOnError false
}