-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
218 lines (182 loc) · 5.78 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
plugins {
id 'java'
id 'eclipse'
}
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
configurations {
debug
}
repositories {
mavenCentral()
}
readVersionNumber()
sourceSets {
basis {
java {
srcDir 'src'
exclude '**/SIM_Constants.java'
}
resources {
srcDir 'src'
exclude '**/SIM_Constants.java'
}
}
main {
java {
source basis.java
srcDir createConstantsDir('release')
}
resources { source basis.resources }
}
debug {
java {
source basis.java
srcDir createConstantsDir('debug')
}
resources { source basis.resources }
}
test {
java { srcDir 'test' }
resources { srcDir 'test' }
}
}
dependencies {
implementation 'javax.xml.bind:jaxb-api:2.3.1', 'com.fifesoft:rsyntaxtextarea:3.1.2'
testCompile 'junit:junit:4.12'
debugImplementation 'javax.xml.bind:jaxb-api:2.3.1', 'com.fifesoft:rsyntaxtextarea:3.1.2'
}
eclipse {
classpath {
minusConfigurations += [configurations.debug]
file {
//if you want to mess with the resulting XML in whatever way you fancy
//closure executed after .classpath content is loaded from existing file
//but before gradle build information is merged
beforeMerged { classpath ->
//you can tinker with the Classpath here
}
//closure executed after .classpath content is loaded from existing file
//and after gradle build information is merged
//removes the release constants from the class path so eclipse doesn't get an exception
whenMerged { classpath ->
classpath.entries = classpath.entries.findAll(
{
entry-> (entry.kind != "src" || (((entry as org.gradle.plugins.ide.eclipse.model.SourceFolder).getName() != null) && (entry as org.gradle.plugins.ide.eclipse.model.SourceFolder).getName().contains( "test" )))
}).plus (new org.gradle.plugins.ide.eclipse.model.SourceFolder("src","bin/main"))/*.plus(new org.gradle.plugins.ide.eclipse.model.SourceFolder("test","bin/test"))*/
/*.collect(
{
entry-> return (entry.kind != "src" ? entry : new org.gradle.plugins.ide.eclipse.model.SourceFolder("src","bin/main"))
}
)*/
}
}
}
}
/**
* Create Version.java from Version.java.template filling in the date and version number
*/
task updateVersionDotJava {
doLast {
def versionFn = 'src/com/stottlerhenke/simbionic/common/Version.java'
def templateFn = versionFn + '.template'
// copy Version.template
def engine = new groovy.text.SimpleTemplateEngine()
def bindings = ['apiVersion': project.apiVersion,
'engineVersion': project.version,
'buildDate': new Date().format('yyyy-MM-dd'),
'buildYear': new Date().format('yyyy')]
def result = engine.createTemplate(file(templateFn)).make(bindings)
file(versionFn).withWriter { result.writeTo it }
}
}
compileJava.dependsOn(updateVersionDotJava)
compileDebugJava.dependsOn(updateVersionDotJava)
jar {
manifest {
attributes('Specification-Title': 'SimBionic',
'Specification-Version': project.ext.apiVersion,
'Specification-Vendor' : 'Stottler Henke Associates, Inc.',
'Implementation-Title': 'SimBionic',
'Implementation-Version': project.version,
'Implementation-Vendor' : 'Stottler Henke Associates, Inc.',
'Main-Class': 'com.stottlerhenke.simbionic.editor.gui.SimBionicFrame')
}
}
task debugJar(type: Jar) {
from sourceSets.debug.output
manifest { from jar.manifest }
baseName 'SimBionic-dev'
}
artifacts {
debug debugJar
}
task dist(type: Zip) {
dependsOn build
//, javadoc
baseName 'simbionic'
into ("$baseName-$version") {
into('lib/') {
from configurations.runtimeClasspath
}
from('.') {
include 'coreActionsPredicates/**'
include 'data/**'
include 'samples/**'
include 'xsl/**'
}
from docsDir
from configure(new File(temporaryDir, 'Run SB Editor.bat')) {
withPrintWriter { pw ->
pw.println "java -cp ${jar.archiveName};./lib/* com.stottlerhenke.simbionic.editor.gui.SimBionicFrame"
pw.println "PAUSE"
}
}
from configurations.runtime.allArtifacts.files
from configurations.debug.allArtifacts.files
}
doLast { bumpVersionNumber() }
}
def readVersionNumber() {
// Get the version number and increment the build number in build/version.properties
def props = new Properties()
file('version.properties').withInputStream {
props.load(it)
}
def apiVersion = props['api-version']
def engineVersion = props['engine-version']
def build = props.build ? props.build.toInteger() : 0
//println "Setting engine version $engineVersion.$build"
project.ext.engineVersion = engineVersion
project.ext.apiVersion = apiVersion
project.ext.buildNumber = build
project.version = "$engineVersion.$build"
}
def bumpVersionNumber() {
def props = new Properties()
//write the version back to the file
props['engine-version'] = engineVersion
props['api-version'] = apiVersion
props.build = (buildNumber + 1).toString();
file('version.properties').withOutputStream {
props.store(it, "SimBionic version Properties")
}
}
def createConstantsDir(debugOrRelease) {
def dir = "$buildDir/tmp/${debugOrRelease}ConstantsSrc"
def debug = debugOrRelease == 'debug'
copy {
includeEmptyDirs = false
into dir
from 'src'
include '**/SIM_Constants.java'
}
fileTree(dir).visit { details ->
if (!details.isDirectory()) {
details.file.text = (details.file.text
.replaceAll("DEBUG_INFO_ON = (true|false)", "DEBUG_INFO_ON = $debug")
.replaceAll("AI_DEBUGGER = (true|false)", "AI_DEBUGGER = $debug"))
}
}
return dir
}