-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
224 lines (200 loc) · 11.9 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
import java.util.regex.Matcher
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'com.diffplug.spotless' version '6.25.0'
}
group 'de.unijena.cheminf'
version '1.2.2.0'
sourceCompatibility = 1.21
//Creates javadoc and sources jars
java {
withJavadocJar()
withSourcesJar()
}
repositories {
mavenCentral()
}
def javaFxVersion = '21.0.1'
def cdkVersion = '2.9'
dependencies {
implementation 'org.jetbrains:annotations:19.0.0'
testImplementation(platform('org.junit:junit-bom:5.9.3'))
testImplementation ('org.junit.jupiter:junit-jupiter')
implementation group: 'org.openscience.cdk', name: 'cdk-bundle', version: cdkVersion
implementation group: 'org.openscience.cdk', name: 'cdk-scaffold', version: '2.8'
implementation group: 'io.github.jonasschaub', name: 'sru', version: '1.4.0.0'
implementation group: 'io.github.jonasschaub', name: 'ErtlFunctionalGroupsFinder', version: '1.3.0.0'
implementation group: 'com.github.librepdf', name: 'openpdf', version: '1.3.26'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux-aarch64'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac-aarch64'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'linux-aarch64'
implementation group: 'org.openjfx', name: 'javafx-swing', version: javaFxVersion, classifier: 'mac-aarch64'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux-aarch64'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac-aarch64'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux-aarch64'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac-aarch64'
}
javafx {
modules = ['javafx.base','javafx.graphics', 'javafx.controls', 'javafx.swing']
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
mainClassName = 'de.unijena.cheminf.mortar.main.Main'
applicationName = 'MORTAR'
applicationDefaultJvmArgs = ["-Xms4g", "-Xmx4g"]
/*
* The unix script still has to be tested!
*/
startScripts {
doLast {
//suppress console window by using javaw instead of java
windowsScript.text = windowsScript.text.replaceAll("java.exe", "javaw.exe")
//use JRE shipped with MORTAR instead of Java installed on the machine and rename method to set the java home to use
windowsScript.text = windowsScript.text.replace("if defined JAVA_HOME goto findJavaFromJavaHome", "goto setJavaFromAppHome\n\n@rem unused because Java home is set in method called above")
windowsScript.text = windowsScript.text.replace(":findJavaFromJavaHome", ":setJavaFromAppHome")
windowsScript.text = windowsScript.text.replace("set JAVA_HOME=%JAVA_HOME:\"=%",
"set JAVA_HOME=%APP_HOME%\\jdk-21.0.1_12_jre\\")
//Merges the exact enumeration of all library jars into one single path giving all the files and subfolders in 'lib'
// This is necessary because lines that are too long cause errors in batch files.
windowsScript.text = windowsScript.text.replaceAll('set CLASSPATH=.*', 'set CLASSPATH=.;%APP_HOME%/lib/*')
//workaround to suppress command window by starting named process "MORTAR" - legacy
//windowsScript.text = windowsScript.text.replace("\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS%", "start \"MORTAR\" \"%JAVA_EXE%\" %DEFAULT_JVM_OPTS%")
//workaround to suppress command window and pass CMD options to MORTAR to suppress the Java version check
windowsScript.text = windowsScript.text.replace("\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MORTAR_OPTS% -classpath \"%CLASSPATH%\" de.unijena.cheminf.mortar.main.Main %*",
"start \"MORTAR\" \"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MORTAR_OPTS% -classpath \"%CLASSPATH%\" de.unijena.cheminf.mortar.main.Main \"-skipJavaVersionCheck\"")
//adjusting error messages
windowsScript.text = windowsScript.text.replace("Please set the JAVA_HOME variable in your environment to match the", "Please check your MORTAR installation,")
windowsScript.text = windowsScript.text.replace("location of your Java installation.", "something must be wrong with the Java Runtime Environment shipped with MORTAR.")
//Merges the exact enumeration of all library jars into one single path giving all the files and subfolders in 'lib' for unix script
unixScript.text = unixScript.text.replaceAll('CLASSPATH=\\Q$\\EAPP_HOME/lib.*', Matcher.quoteReplacement('CLASSPATH=$APP_HOME/lib/*'))
}
}
task updateHeapSpace20GbExtraRunApp(type: CreateStartScripts) {
mainClassName = 'de.unijena.cheminf.mortar.main.Main'
classpath = startScripts.classpath
outputDir = file('build/scripts')
applicationName = 'MORTAR_20GB'
defaultJvmOpts = ["-Xms20g", "-Xmx20g"]
updateHeapSpace20GbExtraRunApp {
doLast {
//suppress console window by using javaw instead of java
windowsScript.text = windowsScript.text.replaceAll("java.exe", "javaw.exe")
//use JRE shipped with MORTAR instead of Java installed on the machine and rename method to set the java home to use
windowsScript.text = windowsScript.text.replace("if defined JAVA_HOME goto findJavaFromJavaHome", "goto setJavaFromAppHome\n\n@rem unused because Java home is set in method called above")
windowsScript.text = windowsScript.text.replace(":findJavaFromJavaHome", ":setJavaFromAppHome")
windowsScript.text = windowsScript.text.replace("set JAVA_HOME=%JAVA_HOME:\"=%",
"set JAVA_HOME=%APP_HOME%\\jdk-21.0.1_12_jre\\")
//Merges the exact enumeration of all library jars into one single path giving all the files and subfolders in 'lib'
// This is necessary because lines that are too long cause errors in batch files.
windowsScript.text = windowsScript.text.replaceAll('set CLASSPATH=.*', 'set CLASSPATH=.;%APP_HOME%/lib/*')
//workaround to suppress command window by starting named process "MORTAR" - legacy
//windowsScript.text = windowsScript.text.replace("\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS%", "start \"MORTAR\" \"%JAVA_EXE%\" %DEFAULT_JVM_OPTS%")
//workaround to suppress command window and pass CMD options to MORTAR to suppress the Java version check
windowsScript.text = windowsScript.text.replace("\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MORTAR_20_GB_OPTS% -classpath \"%CLASSPATH%\" de.unijena.cheminf.mortar.main.Main %*",
"start \"MORTAR\" \"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MORTAR_20_GB_OPTS% -classpath \"%CLASSPATH%\" de.unijena.cheminf.mortar.main.Main \"-skipJavaVersionCheck\"")
//adjusting error messages
windowsScript.text = windowsScript.text.replace("Please set the JAVA_HOME variable in your environment to match the", "Please check your MORTAR installation,")
windowsScript.text = windowsScript.text.replace("location of your Java installation.", "something must be wrong with the Java Runtime Environment shipped with MORTAR.")
//Merges the exact enumeration of all library jars into one single path giving all the files and subfolders in 'lib' for unix script
unixScript.text = unixScript.text.replaceAll('CLASSPATH=\\Q$\\EAPP_HOME/lib.*', Matcher.quoteReplacement('CLASSPATH=$APP_HOME/lib/*'))
}
}
}
applicationDistribution.into("bin") {
duplicatesStrategy= DuplicatesStrategy.EXCLUDE
from(updateHeapSpace20GbExtraRunApp)
fileMode = 0755
}
//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 MORTAR can be started by executing this jar
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'MORTAR Fat Jar File',
'Implementation-Version': archiveVersion,
'Main-Class': mainClassName
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
archiveAppendix = 'fat'
from {
// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') && !it.name.endsWith('aarch64.jar') }.collect { zipTree(it) }
}
with jar
}
task fatJarAarch64(type: Jar) {
manifest {
attributes 'Implementation-Title': 'MORTAR Fat Jar File for AArch64',
'Implementation-Version': archiveVersion,
'Main-Class': mainClassName
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
archiveAppendix = 'fat-aarch64'
from {
// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.findAll {it.name.endsWith('jar') && !it.name.endsWith('linux.jar') && !it.name.endsWith('mac.jar') }.collect { zipTree(it) }
}
with jar
}
//Archives artifacts executed with build
artifacts {
archives fatJar
archives fatJarAarch64
}
//Includes the Adopt Open JDK folder in the project's root directory in the created archives for distribution
distributions {
main {
contents {
from 'AdoptOpenJDK'
into('tutorial'){
from 'Tutorial'
}
}
}
}
spotless {
java {
toggleOffOn() //all code in between spotless:off / spotless:on will be ignored
licenseHeaderFile('License-header/License-header.txt')
encoding 'UTF-8'
cleanthat()
importOrder('com', 'de', 'javafx', 'org', 'javax', 'java')
removeUnusedImports()
indentWithSpaces(4) // doesn't really seem to work...
trimTrailingWhitespace()
endWithNewline()
//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.")
}
}
}
}