forked from draeger-lab/ModelPolisher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
178 lines (161 loc) · 5.11 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
plugins {
id "java"
id "application"
}
// Java versions for compilation and output
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
defaultTasks "clean", "fatJar"
archivesBaseName = "ModelPolisher"
mainClassName = "ModelPolisher"
version = "2.1-beta"
sourceSets {
main {
java {
srcDirs = ["src/main/java"]
}
resources {
srcDirs = ["src/main/resources"]
}
}
test {
java {
srcDirs = ["src/test/java"]
}
}
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
// local dependencies
flatDir {
dirs "lib/de/zbit/SysBio/1390"
}
}
dependencies {
implementation "org.sbml.jsbml:jsbml:1.4"
implementation "de.zbit:SysBio:1390"
implementation "org.postgresql:postgresql:42.2.2"
implementation "org.biojava:biojava-ontology:5.0.0"
implementation 'us.hebi.matlab.mat:mfl-core:0.5.3'
implementation "com.fasterxml.jackson.core:jackson-core:2.10.1"
implementation "com.fasterxml.jackson.core:jackson-databind:2.10.1"
implementation "net.sf.jtidy:jtidy:r938"
implementation "de.uni-rostock.sbi:CombineArchive:1.4.0"
implementation "com.zaxxer:HikariCP:3.4.2"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.5.2"
}
test {
testLogging {
showStandardStreams = true
}
}
// get latest version of MIRIAM registry
task downloadMIRIAM() {
doFirst {
String registry = new URL("https://registry.api.identifiers.org/resolutionApi/getResolverDataset").getText()
File parentDir = new File("src/main/resources/edu/ucsd/sbrg/miriam/");
if (!parentDir.exists()) {
mkdir(parentDir)
}
File registryFile = new File(parentDir.toString() + "/IdentifiersOrg-Registry.json")
BufferedWriter writer = new BufferedWriter(new FileWriter(registryFile))
writer.write(registry)
writer.close()
}
processResources.dependsOn downloadMIRIAM
}
// config for all jar tasks
tasks.withType(Jar) {
dependsOn test
destinationDirectory = file("$rootDir/target")
manifest {
attributes(
"Version": project.version,
"Implementation-Title": "ModelPolisher",
"Implementation-Version": project.version,
"Specification-Vendor": "University of California, San Diego",
"Specification-Title": "ModelPolisher",
"Implementation-Vendor-Id": "edu.ucsd.sbrg",
"Implementation-Vendor": "University of California, San Diego",
"Main-Class": "edu.ucsd.sbrg.bigg.ModelPolisher"
)
}
}
//with dependencies
task fatJar(type: Jar) {
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
}
//build docker container
task devel(type: Exec) {
commandLine "sh", "-c", "cp target/ModelPolisher-" + project.version + ".jar docker/java_docker && " +
"export COMPOSE_FILE=docker-compose.devel.yml && " +
"docker-compose pull && " +
"docker-compose build && " +
"rm docker/java_docker/ModelPolisher-" + project.version + ".jar"
dependsOn fatJar
}
// zip lib folder for release
task zipLibs(type: Zip) {
from "lib"
into "lib"
include "**/**"
archiveFileName = "lib.zip"
destinationDirectory = file("target/")
}
// zip script files for release
task zipScripts(type: Zip) {
from "src/scripts"
into "scripts"
include "**/**"
archiveFileName = "scripts.zip"
destinationDirectory = file("target/")
}
// create lightJar for release
task release() {
dependsOn fatJar
dependsOn tasks["zipLibs"]
dependsOn tasks["zipScripts"]
}
// clean up target directory
clean.doFirst {
file(".gradle").deleteDir()
file("target").deleteDir()
}
// bump jar version in ModelPolisher.sh
if (project.file( "src/scripts/ModelPolisher.sh").exists()) {
task bumpVersionMP() {
replaceVersion(rootProject.projectDir.toString() + "/docker/java_docker/Dockerfile")
replaceVersion(rootProject.projectDir.toString() + "/.travis.yml")
replaceVersion(rootProject.projectDir.toString() + "/README.md")
replaceVersion(rootProject.projectDir.toString() + "/src/scripts/ModelPolisher.sh")
}
processResources.dependsOn bumpVersionMP
}
def replaceVersion(path) {
ArrayList<String> content = new ArrayList<>()
File travisFile = new File(path)
String MPVersion = /ModelPolisher-(.*?)\d{1,2}(.\d{1,2}){1,2}.jar/
travisFile.eachLine {
line ->
content.add(line.replaceAll(MPVersion, "ModelPolisher-" + "${version}.jar"))
}
BufferedWriter writer = new BufferedWriter(new FileWriter(travisFile))
content.each {
line -> writer.writeLine(line)
}
writer.close()
}