forked from JonasSchaub/FragmentFingerprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
272 lines (241 loc) · 9.7 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
/*
* MIT License
*
* Copyright (c) 2023 Betuel Sevindik, Felix Baensch, Jonas Schaub, Christoph Steinbeck, and Achim Zielesny
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
plugins {
id 'application'
id 'org.gradle.java'
id 'jacoco'
id 'java-library'
id 'java'
id("com.diffplug.spotless") version "6.19.0"
id 'org.gradle.maven-publish'
id 'signing'
id("org.sonarqube") version "4.3.1.3277"
}
application {
mainClassName = 'de.unijena.cheminf.fragment.fingerprint.performanceTest.Main'
}
group = 'io.github.jonasschaub'
archivesBaseName = 'FragmentFingerprints'
//see also version for publishing below! And do not forget to update CITATION.cff version as well!!!
version = '1.1.0.0'
//sourceCompatibility = 1.17
//Creates javadoc and sources jars
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withJavadocJar()
withSourcesJar()
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
repositories {
mavenCentral()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/snapshots'
}
}
def cdkVersion = '2.9'
dependencies {
implementation group: 'org.jetbrains', name : 'annotations', version: '23.0.0'
testImplementation(platform('org.junit:junit-bom:5.9.1'))
testImplementation('org.junit.jupiter:junit-jupiter')
implementation group: 'org.openscience.cdk', name: 'cdk-bundle', version: cdkVersion
}
mainClassName = 'de.unijena.cheminf.fragment.fingerprint.performanceTest.Main'
applicationName = 'FragmentFingerprints'
tasks.withType(Test).configureEach {
useJUnitPlatform()
forkEvery = 1
testLogging {
showStandardStreams = true
}
}
//Needed to make the created jar archives executable
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
//Creates a jar archive that includes all dependencies of the project, i.e. that FragmentFingerprints can be started by executing this jar
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Fragmentfingerprints Fat Jar File',
'Implementation-Version': archiveVersion,
'Main-Class': mainClassName
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
archiveAppendix = 'fat'
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
reports {
xml.required = true
}
dependsOn test // tests are required to run before generating the report
}
spotless {
java {
encoding 'UTF-8'
cleanthat()
importOrder('de', 'org', 'com', 'java', 'javax')
removeUnusedImports()
indentWithSpaces(4) // doesn't really seem to work...
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile('License-header/License-header.txt')
//eclipse() //not optimal, because indents with tabs..
//googleJavaFormat() //not optimal, because indents with two spaces...
//palantirJavaFormat() //not optimal, because unnecessary line breaks in head of for loop and corrupts editor folds
//prettier() //needs npm installed, unsuitable...
//clangFormat() //also needs an installation...
custom 'Refuse wildcard imports', {
// Wildcard imports can't be resolved by spotless itself.
// This will require the developer themselves to adhere to best practices.
if (it =~ /\nimport .*\*;/) {
throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
}
}
}
}
sonar {
properties {
property("sonar.projectKey", "JonasSchaub_FragmentFingerprints")
property("sonar.organization", "jonasschaub")
property("sonar.host.url", "https://sonarcloud.io")
}
}
//Archives artifacts executed with build
artifacts {
archives javadocJar, sourcesJar
archives fatJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.github.jonasschaub'
artifactId = 'FragmentFingerprints'
version = '1.1.0.0'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'FragmentFingerprints'
description = 'A library to generate fingerprints for molecular structures based on a set of fragments'
url = 'https://github.com/JonasSchaub/FragmentFingerprints'
//this way, properties can be added:
//properties = [
//myProp: "value",
//"prop.with.dots": "anotherValue"
//]
licenses {
license {
name = 'MIT'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'B-s123'
name = 'Betuel Sevindik'
email = '[email protected]'
url = 'https://github.com/B-s123'
}
developer {
id = 'FelixBaensch'
name = 'Felix Baensch'
email = '[email protected]'
url = 'https://github.com/FelixBaensch'
}
developer {
id = 'JonasSchaub'
name = 'Jonas Schaub'
email = '[email protected]'
url = 'https://github.com/JonasSchaub'
}
developer {
name = 'Christoph Steinbeck'
email = '[email protected]'
url = 'https://cheminf.uni-jena.de/members/steinbeck/'
}
developer {
name = 'Achim Zielesny'
email = '[email protected]'
url = 'https://www.w-hs.de/service/informationen-zur-person/person/zielesny/'
}
}
scm {
connection = 'scm:git:git://github.com/JonasSchaub/FragmentFingerprints.git'
developerConnection = 'scm:git:ssh://github.com/JonasSchaub/FragmentFingerprints.git'
url = 'https://github.com/JonasSchaub/FragmentFingerprints/'
}
}
}
}
repositories {
maven {
//these two lines did not work because dir() apparently asks for a local path
//def releasesRepoUrl = layout.buildDirectory.dir('https://s01.oss.sonatype.org/content/repositories/releases/')
//def snapshotsRepoUrl = layout.buildDirectory.dir('https://s01.oss.sonatype.org/content/repositories/snapshots/')
//TODO: is this actually the way to fully automatically do it?
//def releasesRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/releases/'
//def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
//url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
//after publishing, go to https://s01.oss.sonatype.org, log in, close the staged repo, and release it if everything worked out
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
//uses keys and passwords declared in userhome/.gradle/gradle.properties
//username = property("ossrhUsername") as String
//password = property("ossrhPassword") as String
//uses environment variables declared in yml file which passes GitHub secrets to it
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
signing {
//uses keys and passwords declared in userhome/.gradle/gradle.properties, works locally
//sign publishing.publications.mavenJava
//uses environment variables declared in yml file which passes GitHub secrets to it
def signingKey = System.getenv("signingKey")
def signingPassword = System.getenv("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}