-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
240 lines (210 loc) · 8.74 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
/*
* Copyright (c) 2023 Julian Zander <[email protected]>
* Jonas Schaub <[email protected]>
* Achim Zielesny <[email protected]>
* Christoph Steinbeck <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
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"
}
group = 'io.github.jonasschaub'
archivesBaseName = 'scaffold-graph-vis'
//see also version for publishing below! And do not forget to update CITATION.cff version as well!!!
version = '1.0.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 graphStreamVersion = '2.0'
dependencies {
implementation group: 'org.jetbrains', name: 'annotations', version: '23.0.0'
implementation group: 'org.graphstream', name: 'gs-core', version: graphStreamVersion
implementation group: 'org.graphstream', name: 'gs-ui-swing', version: graphStreamVersion
implementation group: 'org.graphstream', name: 'gs-ui-javafx', version: graphStreamVersion
implementation group: 'org.graphstream', name: 'gs-algo', version: graphStreamVersion
implementation group: 'org.openscience.cdk', name: 'cdk-bundle', version: '2.9'
implementation group: 'org.openscience.cdk', name: 'cdk-scaffold', version: '2.8'
testImplementation(platform('org.junit:junit-bom:5.9.1'))
testImplementation('org.junit.jupiter:junit-jupiter')
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
forkEvery = 1
testLogging {
showStandardStreams = true
}
}
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_scaffold-graph-vis")
property("sonar.organization", "jonasschaub")
property("sonar.host.url", "https://sonarcloud.io")
}
}
artifacts {
archives javadocJar, sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.github.jonasschaub'
artifactId = 'scaffold-graph-vis'
version = '1.0.0.0'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'scaffold-graph-vis'
description = 'Basic utilities for visualising cdk-scaffold graphs using GraphStream'
url = 'https://github.com/JonasSchaub/scaffold-graph-vis'
//this way, properties can be added:
//properties = [
//myProp: "value",
//"prop.with.dots": "anotherValue"
//]
licenses {
license {
name = 'GNU Lesser General Public License v2.1'
url = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html'
}
}
developers {
developer {
id = 'Julian-Z98'
name = 'Julian Zander'
email = 'zanderjulian@gmx'
url = 'https://github.com/Julian-Z98'
}
developer {
id = 'JonasSchaub'
name = 'Jonas Schaub'
email = '[email protected]'
url = 'https://github.com/JonasSchaub'
}
developer {
name = 'Achim Zielesny'
email = '[email protected]'
url = 'https://www.w-hs.de/service/informationen-zur-person/person/zielesny'
}
developer {
name = 'Christoph Steinbeck'
email = '[email protected]'
url = 'https://cheminf.uni-jena.de/members/steinbeck'
}
}
scm {
connection = 'scm:git:git://github.com/JonasSchaub/scaffold-graph-vis.git'
developerConnection = 'scm:git:ssh://github.com/JonasSchaub/scaffold-graph-vis.git'
url = 'https://github.com/JonasSchaub/scaffold-graph-vis/'
}
}
}
}
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
}