Skip to content

Commit b09a943

Browse files
committed
Working Build! Use the actual Engine Version by patching the version.gradle and using some temporary files. Also the build failed due to the suite not paying attention to case-sensitiveness.
1 parent 840328a commit b09a943

1 file changed

Lines changed: 47 additions & 14 deletions

File tree

build.gradle

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'java';
2+
import org.apache.tools.ant.filters.*
3+
def jmePomVersion = "";
24

35
task downloadSuite << {
46
def suite_folder = "suite" // Is not completely implemented yet.
@@ -38,25 +40,56 @@ task suite(dependsOn: applySuitePath) << {
3840

3941
}
4042

41-
task assemble(dependsOn: suite, overwrite: true) << {
43+
task CreateVersionFile(dependsOn: suite) << {
44+
// Since it's a bit problematic to call version.gradle from a different directory and project (it won't pick the right repo, it won't export the vars), we copy and patch it a bit
45+
46+
copy {
47+
from 'suite/engine'
48+
into '.'
49+
include 'version.gradle'
50+
filter { line ->
51+
line = line.replace("def grgit = Grgit.open(project.file('.'))", "def grgit = Grgit.open(project.file('suite/engine/'))")
52+
line = line.replace("import java.text.SimpleDateFormat", "ext.jmeVersion = \"3.1.0\"\n" +
53+
"ext.jmeMainVersion = \"3.1\"\n" +
54+
"ext.jmeVersionTag = \"SNAPSHOT\"\n" +
55+
"ext.jmeVersionTagID = \"0\"\n" +
56+
"import java.text.SimpleDateFormat")
57+
} // Properties and git repo
58+
59+
def f = file("task.tmp")
60+
f.text = "task writeVersion(dependsOn: configureVersionInfo) << {\n" + // since I can't find a way to access those version files..
61+
"\tdef f1 = file(\"version.txt\")\n"+
62+
"\tf1.text = jmePomVersion\n"+
63+
"}\n"
64+
65+
filter(ConcatFilter, append: f)
66+
}
67+
68+
delete(file("task.tmp"))
69+
}
70+
71+
task getEngineVersion(type: GradleBuild, dependsOn: CreateVersionFile) {
72+
buildFile = "version.gradle"
73+
tasks = ['writeVersion'] // Our injected task.
74+
75+
doLast {
76+
def f = file("version.txt")
77+
jmePomVersion = f.text
78+
delete(f)
79+
delete("version.gradle")
80+
}
81+
}
82+
83+
task assemble(dependsOn: [suite, getEngineVersion], overwrite: true) << {
4284
println "Setting myself as the module to be compiled..."
4385
ant.propertyfile(file: "suite/nbproject/project.properties") {
4486
entry(key: "project.com.jme3.ai", value: "../") // Set the current directory as directory for module
4587
entry(key: "modules", value: '${project.com.jme3.ai}')
4688
}
4789

48-
println "Manually fixing/adding Library Entries (jMonkey Version)"
49-
90+
println "Manually fixing/adding Library Entries (jMonkey Version):"
5091
ant.propertyfile(file: "suite/nbproject/jme-project-libs.properties") {
51-
def jmeVersion = "";
52-
53-
if (System.getenv("TRAVIS").equals("true")) { // TODO: Replace with engine/version.gradle
54-
jmeVersion = "3.1.0-master-SNAPSHOT"
55-
} else {
56-
jmeVersion = "3.1.0-SNAPSHOT" // Local Builds don't contain the branch for some reason
57-
}
58-
59-
entry(key: "jme3-version-string", value: jmeVersion)
92+
entry(key: "jme3-version-string", value: jmePomVersion)
6093
/*entry(key: 'libs.jme3.dir', value:'/Users/MeFisto94/Documents/Coding/jme3-artificial-intelligence/suite/libs')
6194
6295
file("suite/nbproject/jme-project-libs.properties").withReader { reader ->
@@ -70,9 +103,9 @@ task assemble(dependsOn: suite, overwrite: true) << {
70103
}
71104

72105
//ant.ant(dir: ".", antfile: "build.xml") // Already called by nbm
73-
println "Building Netbeans Modules"
74106
// ant.ant(dir: ".", antfile: "build.xml", target: "nbm") // Note: for some reason, the nbm target isn't really executed?
107+
println "Building Netbeans Modules"
75108
exec {
76109
commandLine 'ant', 'nbm'
77110
}
78-
}
111+
}

0 commit comments

Comments
 (0)