-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
253 lines (221 loc) · 8.23 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
plugins {
id 'java-library'
id "com.github.hierynomus.license" version "0.15.0"
id "com.github.johnrengelman.shadow" version "5.0.0"
id "net.researchgate.release" version "2.6.0"
id "com.github.breadmoirai.github-release" version "2.2.11"
id 'io.codearte.nexus-staging' version '0.12.0'
}
project.ext {
jUnitVersion = '5.5.0'
}
apply plugin:'java'
apply plugin:'maven'
apply plugin:'signing'
apply plugin:'com.github.hierynomus.license'
apply plugin:'com.github.johnrengelman.shadow'
apply plugin: 'net.researchgate.release'
apply plugin: "com.github.breadmoirai.github-release"
apply plugin: 'io.codearte.nexus-staging'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30'
}
test {
useJUnitPlatform()
systemProperties['junit.jupiter.execution.parallel.enabled'] = true
if (Runtime.runtime.availableProcessors()>=4){
maxParallelForks = Runtime.runtime.availableProcessors()-2
}
else{
maxParallelForks = Runtime.runtime.availableProcessors()
}
minHeapSize = "4g"
maxHeapSize = "8g"
}
license {
header rootProject.file('src/main/resources/license.txt')
strictCheck false
ext.year = Calendar.getInstance().get(Calendar.YEAR)
include "**/*.java"
exclude "**/*package-info.java"
}
sourceSets {
main {
java {srcDirs=["src/main/java"]}
resources {srcDirs=["src/main/resources"]}
}
test {
java {srcDirs=["src/test/java"]}
resources {srcDirs=["src/test/resources"]}
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
/* Custom task to create a fat-jar containing all main and test
sources as compiled class files and all necessary dependencies.
The resulting fat-jar is necessary for running the PerformanceTester-Class
on the Linux shell where one can not use a developement environment like Eclipse.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
task sourcesAndTestsJar(type: ShadowJar) {
classifier = 'jar-with-tests-and-all-depedencies'
project.configurations.implementation.canBeResolved = true
configurations = [project.configurations.implementation]
from sourceSets.main.output+sourceSets.test.allSource+sourceSets.test.output
}
shadowJar {
classifier = 'jar-with-dependencies'
}
artifacts {
archives javadocJar, sourcesJar, shadowJar
}
if(!project.hasProperty('signing.keyId') || !project.hasProperty('signing.password')|| !project.hasProperty('signing.secretKeyRingFile')){
println "WARNING: If you want to sign your archives please provide the 'signing.keyId' and 'signing.password' and 'signing.secretKeyRingFile' properties"
}
else{
signing {
sign configurations.archives
}
}
uploadArchives {
repositories {
mavenDeployer {
if(!project.hasProperty('nexusUsername') || !project.hasProperty('nexusPassword')){
println "WARNING: If you want to release to Sonatype please provide the 'nexusUsername' and 'nexusPassword' properties"
}
else{
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: nexusUsername, password: nexusPassword)
if(project.hasProperty('systemProp.https.proxyHost') && project.hasProperty('systemProp.https.proxyPort')){
println "INFO: Using system proxy for upload : "+System.properties['https.proxyHost']+":"+System.properties['https.proxyPort']
proxy(host: System.properties['https.proxyHost'], port: System.properties['https.proxyPort'] as Integer, type: 'http')
}
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: nexusUsername, password: nexusPassword)
if(project.hasProperty('systemProp.https.proxyHost') && project.hasProperty('systemProp.https.proxyPort')){
println "INFO: Using system proxy for upload : "+System.properties['https.proxyHost']+":"+System.properties['https.proxyPort']
proxy(host: System.properties['https.proxyHost'], port: System.properties['https.proxyPort'] as Integer, type: 'http')
}
}
}
pom.project {
name = projectname
packaging = 'jar'
artifactId = projectname
description = projectdescription
url = projecturl
scm {
connection 'scm:git:https://github.com/IPK-BIT/isa4j.git'
developerConnection 'scm:git:https://github.com/IPK-BIT/isa4j.git'
url 'https://github.com/IPK-BIT/isa4j.git'
}
licenses {
license {
name 'MIT License'
url 'https://spdx.org/licenses/MIT.html'
}
}
developers {
developer {
name 'Dennis Psaroudakis'
email '[email protected]'
organization = 'IPK Gatersleben'
organizationUrl 'http://www.ipk.gatersleben.de'
}
developer {
name 'Dr. Daniel Arend'
email '[email protected]'
organization = 'IPK Gatersleben'
organizationUrl 'http://www.ipk.gatersleben.de'
}
}
}
}
}
}
uploadArchives.dependsOn test
nexusStaging {
if(project.hasProperty('nexusUsername') && project.hasProperty('nexusPassword')){
stagingProfileId = "isa4j_ipk_gatersleben_de"
username = nexusUsername
password = nexusPassword
}
}
release {
failOnCommitNeeded = false
failOnPublishNeeded = true
failOnSnapshotDependencies = true
failOnUnversionedFiles = true
failOnUpdateNeeded = true
revertOnFail = true
preCommitText = ''
preTagCommitMessage = '[gradle-release-plugin] - prepare release '
tagCommitMessage = '[gradle-release-plugin] - creating tag: '
newVersionCommitMessage = '[gradle-release-plugin] - prepare for next development iteration '
tagTemplate = "isa4j-"+'$version'
versionPropertyFile = 'gradle.properties'
versionProperties = []
buildTasks = []
scmAdapters = [
net.researchgate.release.GitAdapter
]
git {
requireBranch = 'master'
pushToRemote = 'origin'
pushToBranchPrefix = ''
commitVersionFileOnly = false
signTag = false
}
}
//skip the task to tag this relsase because it is done by the githubRelease task
createReleaseTag.enabled = false
//project.tasks.afterReleaseBuild.dependsOn project.collect({it.getTasks().getByName("githubRelease")})
project.tasks.afterReleaseBuild.dependsOn project.collect({it.getTasks().getByName("uploadArchives")})
githubRelease {
// This is your personal access token with Repo permissions
// You get this from your user settings > developer settings > Personal Access Tokens
if(project.hasProperty('githubtoken')){
token githubtoken
}
owner "IPK-BIT"
repo "isa4j"
tagName "isa4j-"+ "${project.version}"
targetCommitish "master"
releaseName "isa4j-"+ "${project.version}"
body ""
draft false
prerelease false
// releaseAssets jar.destinationDir // this points to which files you want to upload as assets with your release
releaseAssets.from("build/libs/isa4j-${project.version}-jar-with-dependencies.jar","build/libs/isa4j-${project.version}.jar","build/libs/isa4j-${project.version}-sources.jar","build/libs/isa4j-${project.version}-javadoc.jar")
overwrite false
dryRun false
apiEndpoint "https://api.github.com"
}
afterReleaseBuild.finalizedBy('githubRelease')
task copyJavaDocs(type: Copy) {
from 'build/docs/javadoc'
into 'docs/javadoc'
}
copyJavaDocs.dependsOn(javadoc)
javadocJar.finalizedBy(copyJavaDocs)