build.gradle 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. //ant.importBuild 'build.xml'
  2. import groovy.xml.MarkupBuilder
  3. import java.util.zip.ZipFile
  4. apply from: 'gradle/libs/digest.gradle'
  5. apply from: file('version.gradle')
  6. if (!hasProperty('mainClass')) {
  7. ext.mainClass = ''
  8. }
  9. repositories {
  10. mavenLocal()
  11. jcenter {
  12. url "http://jcenter.bintray.com/"
  13. }
  14. maven {
  15. url "http://updates.jmonkeyengine.org/maven/"
  16. }
  17. maven {
  18. url 'http://nifty-gui.sourceforge.net/nifty-maven-repo/'
  19. }
  20. maven { url "https://jitpack.io" }
  21. }
  22. if (System.getenv('TRAVIS') != null) {
  23. /*if (System.env.TRAVIS_TAG != "") {
  24. ext.jmeEngineVersion = "3.1.0-" + System.env.TRAVIS_TAG + "-SNAPSHOT"
  25. } else {*/
  26. ext.jmeEngineVersion = "3.1.0-stable" // Use Beta 2 instead of 3.1.0-master-SNAPSHOT
  27. //}
  28. } else {
  29. ext.jmeEngineVersion = "3.1.0-stable" // In case you build of the HEAD of 3.1, you need to change that to 3.1.0-SNAPSHOT again
  30. }
  31. configurations {
  32. corelibs
  33. optlibs
  34. testdatalibs
  35. examplelibs
  36. }
  37. dependencies {
  38. corelibs dep("com.github.xbuf:jme3_xbuf:0.9.1", false, false)
  39. corelibs dep("org.jmonkeyengine:jme3-core:$jmeEngineVersion", true, true)
  40. corelibs dep("org.jmonkeyengine:jme3-desktop:$jmeEngineVersion", true, true)
  41. corelibs dep("org.jmonkeyengine:jme3-lwjgl:$jmeEngineVersion", true, true)
  42. corelibs dep("org.jmonkeyengine:jme3-effects:$jmeEngineVersion", true, true)
  43. corelibs dep("org.jmonkeyengine:jme3-blender:$jmeEngineVersion", true, true)
  44. corelibs dep("org.jmonkeyengine:jme3-bullet:$jmeEngineVersion", true, true)
  45. corelibs dep("org.jmonkeyengine:jme3-bullet-native:$jmeEngineVersion", true, true)
  46. corelibs dep(fileTree("lib"), false, false)
  47. corelibs dep("org.jmonkeyengine:jme3-jogg:$jmeEngineVersion", true, true)
  48. corelibs dep("org.jmonkeyengine:jme3-networking:$jmeEngineVersion", true, true)
  49. corelibs dep("org.jmonkeyengine:jme3-niftygui:$jmeEngineVersion", true, true)
  50. corelibs dep("org.jmonkeyengine:jme3-plugins:$jmeEngineVersion", true, true)
  51. corelibs dep("org.jmonkeyengine:jme3-terrain:$jmeEngineVersion", true, true)
  52. optlibs dep("org.jmonkeyengine:jme3-jbullet:$jmeEngineVersion", true, true)
  53. optlibs dep("org.jmonkeyengine:jme3-jogl:$jmeEngineVersion", true, true)
  54. optlibs dep("org.jmonkeyengine:jme3-android:$jmeEngineVersion", true, true)
  55. optlibs dep("org.jmonkeyengine:jme3-ios:$jmeEngineVersion", true, true)
  56. optlibs dep("org.jmonkeyengine:jme3-android-native:$jmeEngineVersion", true, true)
  57. optlibs dep("org.jmonkeyengine:jme3-bullet-native-android:$jmeEngineVersion", true, true)
  58. testdatalibs dep("org.jmonkeyengine:jme3-testdata:$jmeEngineVersion", false, false)
  59. examplelibs dep("org.jmonkeyengine:jme3-examples:$jmeEngineVersion", false, true)
  60. }
  61. def dep(coords, javadoc = false, sources = false) {
  62. def result = [dependencies.create(coords)]
  63. if (javadoc) result << dependencies.create("$coords:javadoc")
  64. if (sources) result << dependencies.create("$coords:sources")
  65. result
  66. }
  67. artifacts {
  68. // jar null
  69. }
  70. task checkPlatformConfig {
  71. description = "Downloads the NetBeans platform base and registers it in the SDK project if needed"
  72. def platformFile = file("nbproject/private/platform-private.properties")
  73. if(!platformFile.exists()){
  74. def netbeansFolder = file("netbeans")
  75. if(!netbeansFolder.exists() || netbeansFolder.list().length == 0){
  76. println "Downloading NetBeans Platform base, this only has to be done once.."
  77. def f = file("netbeans.zip")
  78. new URL(netbeansUrl).withInputStream{ i -> f.withOutputStream{ it << i }}
  79. copy{
  80. from zipTree(f)
  81. into "."
  82. }
  83. f.delete()
  84. }
  85. file("nbproject/private/").mkdirs()
  86. platformFile.createNewFile()
  87. platformFile.write("nbplatform.default.netbeans.dest.dir=${netbeansFolder.absolutePath.replace('\\','/')}\r\n"+\
  88. "nbplatform.default.harness.dir=${netbeansFolder.absolutePath.replace('\\','/')}/harness\r\n")
  89. }
  90. }
  91. task copyBaseLibs(dependsOn:configurations.corelibs) <<{
  92. description "Copies the library files needed to run the SDK to "+
  93. "jme3-core-baselibs and jme3-core-libraries"
  94. // for each dependency in corelibs..
  95. //project.configurations.corelibs.dependencies.each {dep ->
  96. //println(project.configurations.corelibs.dependencies)
  97. project.configurations.corelibs.collect {file ->
  98. // copy built jme3 jar files to jme3-core-baselibs
  99. if (file.name.startsWith("jme3") && !isSourceOrJavadoc(file.name)){
  100. copy {
  101. from file
  102. into "jme3-core-baselibs/release/modules/ext/"
  103. }
  104. }else if( !isSourceOrJavadoc(file.name)){
  105. copy {
  106. from file
  107. into "jme3-core-libraries/release/modules/ext/"
  108. }
  109. }
  110. }
  111. }
  112. copyBaseLibs.inputs.files configurations.corelibs.resolve()
  113. copyBaseLibs.outputs.dir "jme3-core-baselibs/release/modules/ext/"
  114. copyBaseLibs.outputs.dir "jme3-core-libraries/release/modules/ext/"
  115. def isSourceOrJavadoc(dep){
  116. return isSource(dep) || isJavadoc(dep)
  117. }
  118. def isSource(dep){
  119. return dep.endsWith("-sources.jar")
  120. }
  121. def isJavadoc(dep){
  122. return dep.endsWith("-javadoc.jar")
  123. }
  124. def isJmeDep(dep) {
  125. return dep.startsWith("jme3")
  126. }
  127. task createBaseXml(dependsOn: configurations.corelibs) <<{
  128. description "Creates the project.xml files for "+
  129. "jme3-core-baselibs and jme3-core-libraries"
  130. def jmeJarFiles = [] // jme3 jar files
  131. def externalJarFiles = [] // external jar files
  132. // collect jar files
  133. project.configurations.corelibs.collect {file ->
  134. // copy built jme3 jar files to jme3-core-baselibs
  135. if (file.name.startsWith("jme3") && !isSourceOrJavadoc(file.name)){
  136. //collect jme jars
  137. if(!jmeJarFiles.contains(file)) {
  138. jmeJarFiles.add(file)
  139. }
  140. } else if(!isSourceOrJavadoc(file.name)) {
  141. //collect external jars
  142. externalJarFiles.add(file)
  143. }
  144. }
  145. // collect base packages
  146. def packages = []
  147. jmeJarFiles.each{jarFile ->
  148. ZipFile file = new ZipFile(jarFile)
  149. file.entries().each { entry ->
  150. if(entry.name.endsWith('.class')){
  151. // TODO: "/" works on windows?
  152. def pathPart = entry.name.substring(0,entry.name.lastIndexOf('/'))
  153. def classPath = pathPart.replace('/','.');
  154. if(!packages.contains(classPath)){
  155. packages.add(classPath)
  156. }
  157. }
  158. }
  159. }
  160. // collect library packages
  161. def extPackages = []
  162. externalJarFiles.each{jarFile ->
  163. ZipFile file = new ZipFile(jarFile)
  164. file.entries().each { entry ->
  165. if(entry.name.endsWith('.class')){
  166. // TODO: "/" works on windows?
  167. def pathPart = entry.name.substring(0,entry.name.lastIndexOf('/'))
  168. def classPath = pathPart.replace('/','.');
  169. if(!extPackages.contains(classPath)){
  170. extPackages.add(classPath)
  171. }
  172. }
  173. }
  174. }
  175. def writer = new StringWriter()
  176. def xml = new MarkupBuilder(writer)
  177. xml.mkp.xmlDeclaration(version:'1.0')
  178. xml.project(xmlns:"http://www.netbeans.org/ns/project/1"){
  179. type "org.netbeans.modules.apisupport.project"
  180. configuration {
  181. data(xmlns:"http://www.netbeans.org/ns/nb-module-project/3") {
  182. "code-name-base" "com.jme3.gde.core.baselibs"
  183. "suite-component"{}
  184. "module-dependencies"{
  185. dependency{
  186. "code-name-base" "com.jme3.gde.core.libraries"
  187. "build-prerequisite"{}
  188. "compile-dependency"{}
  189. "run-dependency"{
  190. "release-version" "1"
  191. "specification-version" jmeVersion
  192. }
  193. }
  194. }
  195. "public-packages"{
  196. packages.each{
  197. "package" it
  198. }
  199. }
  200. jmeJarFiles.each{jarFile ->
  201. "class-path-extension"{
  202. "runtime-relative-path" "ext/${jarFile.name}"
  203. "binary-origin" "release/modules/ext/${jarFile.name}"
  204. }
  205. }
  206. }
  207. }
  208. }
  209. // write XML file
  210. File baselibsProjectFile = file("jme3-core-baselibs/nbproject/project.xml");
  211. baselibsProjectFile.write(writer.toString())
  212. def extWriter = new StringWriter()
  213. def extXml = new MarkupBuilder(extWriter)
  214. // extXml.mkp.xmlDeclaration(version:'1.0')
  215. extXml.project(xmlns:"http://www.netbeans.org/ns/project/1"){
  216. type "org.netbeans.modules.apisupport.project"
  217. configuration {
  218. data(xmlns:"http://www.netbeans.org/ns/nb-module-project/3") {
  219. "code-name-base" "com.jme3.gde.core.libraries"
  220. "suite-component"{}
  221. "module-dependencies"{}
  222. "public-packages"{
  223. extPackages.each{
  224. "package" it
  225. }
  226. }
  227. externalJarFiles.each{jarFile ->
  228. "class-path-extension"{
  229. "runtime-relative-path" "ext/${jarFile.name}"
  230. "binary-origin" "release/modules/ext/${jarFile.name}"
  231. }
  232. }
  233. }
  234. }
  235. }
  236. // write XML file
  237. File librariesProjectFile = file("jme3-core-libraries/nbproject/project.xml");
  238. librariesProjectFile.write(extWriter.toString())
  239. }
  240. createBaseXml.inputs.files configurations.corelibs.resolve()
  241. createBaseXml.outputs.file "jme3-core-baselibs/nbproject/project.xml"
  242. createBaseXml.outputs.file "jme3-core-libraries/nbproject/project.xml"
  243. task copyProjectLibs(dependsOn: [configurations.corelibs, configurations.testdatalibs]) <<{
  244. description "Copies the jar files needed to supply the J2SE Libraries in the "+
  245. "SDK to jme3-project-baselibs and jme3-project-libraries"
  246. // for each dependency in corelibs and optlibs..
  247. def deps = []
  248. deps.addAll(project.configurations.corelibs.files)
  249. deps.addAll(project.configurations.optlibs.files)
  250. deps.each {dep ->
  251. // copy jme3 jar files, sources and javadocs to jme3-project-baselibs
  252. if(isSource(dep.name)){
  253. copy {
  254. from dep
  255. into "jme3-project-baselibs/release/libs/"
  256. }
  257. } else if(isJavadoc(dep.name)){
  258. copy {
  259. from dep
  260. into "jme3-project-baselibs/release/libs/"
  261. }
  262. } else if(isJmeDep(dep.name)){
  263. copy {
  264. from dep
  265. into "jme3-project-baselibs/release/libs/"
  266. }
  267. } else{
  268. copy {
  269. from dep
  270. into "jme3-project-libraries/release/libs/"
  271. }
  272. }
  273. }
  274. project.configurations.testdatalibs.files.each {dep ->
  275. // copy jme3 test data to jme3-project-testdata
  276. if(isJmeDep(dep.name)){
  277. copy {
  278. from dep
  279. into "jme3-project-testdata/release/libs/"
  280. rename ("jme3-testdata(.*)", "jme3-testdata.jar")
  281. }
  282. }
  283. }
  284. }
  285. copyProjectLibs.inputs.files configurations.corelibs.resolve()
  286. copyProjectLibs.inputs.files configurations.optlibs.resolve()
  287. copyProjectLibs.inputs.files configurations.testdatalibs.resolve()
  288. copyProjectLibs.outputs.dir "jme3-project-baselibs/release/libs/"
  289. copyProjectLibs.outputs.dir "jme3-project-libraries/release/libs/"
  290. copyProjectLibs.outputs.dir "jme3-project-testdata/release/libs/"
  291. // workaround method to add a tag with the name "name" and "file" to an XML MarkupBuilder
  292. def makeName(builder, nameR) { builder.name nameR }
  293. def makeFile(builder, nameR) { builder.file(name:nameR, url:nameR) }
  294. task createProjectXml(dependsOn: configurations.corelibs) <<{
  295. description "Creates needed J2SE library and layer XML files in jme3-project-baselibs"
  296. def eol = System.properties.'line.separator'
  297. def j2seLibraries = [] // created J2SE library descriptors
  298. // for each dependency in corelibs..
  299. def deps = []
  300. deps.addAll(project.configurations.corelibs.dependencies)
  301. deps.addAll(project.configurations.optlibs.dependencies)
  302. deps.each {dep ->
  303. def jmeJarFiles = [] // jme3 jar files
  304. def jmeSourceFiles = [] // jme3 sources
  305. def jmeJavadocFiles = [] // jme3 javadoc
  306. def externalJarFiles = [] // external jar files
  307. if(j2seLibraries.contains(dep.name+".xml")){
  308. return;
  309. }
  310. j2seLibraries.add(dep.name+".xml")
  311. project.configurations.corelibs.files{ d -> return d.name == dep.name}.each{ file ->
  312. if(isSource(file.name)){
  313. if(!jmeSourceFiles.contains(file.name)){
  314. jmeSourceFiles.add(file.name)
  315. }
  316. } else if(isJavadoc(file.name)){
  317. if(!jmeJavadocFiles.contains(file.name)){
  318. jmeJavadocFiles.add(file.name)
  319. }
  320. } else if(isJmeDep(file.name)){
  321. if(!jmeJarFiles.contains(file.name)){
  322. jmeJarFiles.add(file.name)
  323. }
  324. } else{
  325. if(!externalJarFiles.contains(file.name)){
  326. externalJarFiles.add(file.name)
  327. }
  328. }
  329. }
  330. project.configurations.optlibs.files{ d -> return d.name == dep.name}.each{ file ->
  331. if(isSource(file.name)){
  332. if(!jmeSourceFiles.contains(file.name)){
  333. jmeSourceFiles.add(file.name)
  334. }
  335. } else if(isJavadoc(file.name)){
  336. if(!jmeJavadocFiles.contains(file.name)){
  337. jmeJavadocFiles.add(file.name)
  338. }
  339. } else if(isJmeDep(file.name)){
  340. if(!jmeJarFiles.contains(file.name)){
  341. jmeJarFiles.add(file.name)
  342. }
  343. } else {
  344. if(!externalJarFiles.contains(file.name)){
  345. externalJarFiles.add(file.name)
  346. }
  347. }
  348. }
  349. // Workarounds where the automatic dependency detection did not work. This is mainly when there are runtime dependencies which are not available as artifacts
  350. if (dep.name.equals("jme3-jbullet")) {
  351. externalJarFiles.add("jbullet.jar")
  352. externalJarFiles.add("stack-alloc.jar")
  353. }
  354. // create J2SE library descriptor xml file
  355. def libraryWriter = new StringWriter()
  356. def libraryXml = new MarkupBuilder(libraryWriter)
  357. // xml.mkp.xmlDeclaration(version:'1.0')
  358. libraryWriter << '<?xml version="1.0" encoding="UTF-8"?>' << eol
  359. libraryWriter << '<!DOCTYPE library PUBLIC "-//NetBeans//DTD Library Declaration 1.0//EN" "http://www.netbeans.org/dtds/library-declaration-1_0.dtd">' << eol
  360. libraryXml.library(version:"1.0", encoding: "UTF-8"){
  361. makeName(libraryXml, "${dep.name}")
  362. type "j2se"
  363. "localizing-bundle" "com.jme3.gde.project.baselibs.Bundle"
  364. volume{
  365. type "classpath"
  366. resource "jar:nbinst://com.jme3.gde.project.baselibs/libs/${jmeJarFiles[0]}!/"
  367. /* Usually we don't add all the jmeJarFiles, this is because e.g. each library depends on core,
  368. * some depend on jme3-terrain etc, but it's the users duty to add the correct libraries.
  369. * If we would add all those each library would have it's one jme3-core, which might even lead
  370. * to build errors then.
  371. */
  372. if (dep.name.equals("jme3_xbuf")) {
  373. jmeJarFiles.each{jar ->
  374. if (jar.startsWith("jme3_xbuf")) {
  375. /* Technically you would only need the loaders, not the spatial viewer,
  376. * but users can edit the library if they want to strip off
  377. * the last few possible kilobytes */
  378. resource "jar:nbinst://com.jme3.gde.project.baselibs/libs/$jar!/"
  379. }
  380. }
  381. }
  382. externalJarFiles.each{jar ->
  383. resource "jar:nbinst://com.jme3.gde.project.libraries/libs/${jar}!/"
  384. }
  385. }
  386. volume{
  387. type "src"
  388. jmeSourceFiles.each{jar ->
  389. resource "jar:nbinst://com.jme3.gde.project.baselibs/libs/${jar}!/"
  390. }
  391. }
  392. volume{
  393. type "javadoc"
  394. jmeJavadocFiles.each{jar ->
  395. resource "jar:nbinst://com.jme3.gde.project.baselibs/libs/${jar}!/"
  396. }
  397. }
  398. }
  399. // write XML file
  400. File libraryXmlFile = file("jme3-project-baselibs/src/com/jme3/gde/project/baselibs/${dep.name}.xml");
  401. libraryXmlFile.write(libraryWriter.toString())
  402. }
  403. // create layer.xml file with entries of library xml files
  404. def layerWriter = new StringWriter()
  405. def layerXml = new MarkupBuilder(layerWriter)
  406. // layerXml.mkp.xmlDeclaration(version:'1.0')
  407. layerWriter << '<?xml version="1.0" encoding="UTF-8"?>' << eol
  408. layerWriter << '<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">' << eol
  409. layerXml.filesystem{
  410. folder(name:"org-netbeans-api-project-libraries"){
  411. folder(name:"Libraries"){
  412. j2seLibraries.each{lib ->
  413. makeFile(layerXml, lib)
  414. }
  415. }
  416. }
  417. }
  418. File layerXmlFile = file("jme3-project-baselibs/src/com/jme3/gde/project/baselibs/layer.xml");
  419. layerXmlFile.write(layerWriter.toString())
  420. }
  421. createProjectXml.inputs.files configurations.corelibs.resolve()
  422. createProjectXml.inputs.files configurations.optlibs.resolve()
  423. createProjectXml.outputs.dir "jme3-project-baselibs/src/com/jme3/gde/project/baselibs/"
  424. task copyTestSources <<{
  425. project.configurations.examplelibs.files.each{dep ->
  426. if(isSource(dep.name)){
  427. copy{
  428. from {
  429. zipTree(dep)
  430. }
  431. into "JME3TestsTemplate/src/"
  432. }
  433. copy{
  434. from {
  435. zipTree(dep)
  436. }
  437. into "JME3TestsTemplateAndroid/src/"
  438. }
  439. }
  440. }
  441. }
  442. copyTestSources.inputs.files project.configurations.examplelibs
  443. copyTestSources.outputs.dir "JME3TestsTemplate/src/"
  444. copyTestSources.outputs.dir "JME3TestsTemplateAndroid/src/"
  445. ant.properties['plugins.version'] = jmeVersion
  446. ant.properties['app.version']= jmePomVersion
  447. ant.properties['nbm.revision']= jmeNbmRevision
  448. task overrideHarness(dependsOn: checkPlatformConfig) << {
  449. def props = new Properties()
  450. props.load(new FileInputStream("harness-override/override.properties"))
  451. def patch_file = { f ->
  452. def g = file("harness-override/" + f.getName())
  453. if (!f.exists()) {
  454. throw new GradleException('Cannot find targetFile: ' + f.getAbsolutePath());
  455. }
  456. if (!g.exists()) {
  457. throw new GradleException('Cannot find sourceFile: ' + g.getAbsolutePath());
  458. }
  459. if (getSHA256Hash(f) == props[f.getName() + ".hashAfter"]) {
  460. println "> Harness file \"" + f.getName() + "\" is already patched!"
  461. return; /* Already patched */
  462. }
  463. if (getSHA256Hash(f) == props[f.getName() + ".hashBefore"]) {
  464. println "> Will patch harness file \"" + f.getName() + "\"!"
  465. if (getSHA256Hash(g) != props[g.getName() + ".hashAfter"]) {
  466. throw new GradleException("Dangerous Checksum Mismatch: sourceFile \"" + g.getName() + "\" doesn't equal to its hashAfter hash. This probably means someone changed this file but forgot to update said hash or someone tried to invade the SDK by spreading his exe.")
  467. }
  468. copy {
  469. from g
  470. into f.getParent()
  471. }
  472. } else {
  473. throw new GradleException('Checksum Mismatch: targetFile ' + f.getName() + ' has invalid hash ' + getSHA256Hash(f) + '. Did you update Netbeans without changing harness-override/override.properties?');
  474. }
  475. }
  476. patch_file(file("netbeans/harness/launchers/app.exe"));
  477. patch_file(file("netbeans/harness/launchers/app64.exe"));
  478. patch_file(file("netbeans/harness/launchers/pre7_app.exe"));
  479. }
  480. overrideHarness.outputs.files([ 'netbeans/harness/launchers/app.exe', 'netbeans/harness/launchers/app64.exe', 'netbeans/harness/launchers/pre7_app.exe'])
  481. overrideHarness.inputs.files([ 'netbeans/harness/launchers/app.exe', 'netbeans/harness/launchers/app64.exe', 'netbeans/harness/launchers/pre7_app.exe', 'harness-override/override.properties'])
  482. task downloadAvian() << {
  483. def avianFile = file("jme3-ios/src/com/jme3/gde/ios/avian-openjdk-mac.zip")
  484. if (!avianFile.exists())
  485. {
  486. new URL('https://bintray.com/mefisto94/jme-sdk-storage/download_file?file_path=avian-openjdk-mac.zip').withInputStream{ i -> avianFile.withOutputStream{ it << i }}
  487. }
  488. }
  489. task buildSdk(dependsOn: [copyBaseLibs, copyProjectLibs, createProjectXml, createBaseXml, copyTestSources, overrideHarness, downloadAvian]) <<{
  490. ant.propertyfile(file: "nbproject/project.properties") {
  491. entry( key: "plugins.version", value: "${jmeVersion}")
  492. entry( key: "app.version", value: "${jmePomVersion}")
  493. entry( key: "nbm.revision", value: "${jmeNbmRevision}")
  494. }
  495. ant.ant(dir: ".", antfile: "build.xml", target: "build")
  496. }
  497. buildSdk.inputs.files configurations.corelibs.resolve()
  498. buildSdk.inputs.files configurations.optlibs.resolve()
  499. file('.').eachDir{
  500. if(it.name.startsWith("jme3-") && it.isDirectory()){
  501. buildSdk.inputs.dir it
  502. }
  503. }
  504. buildSdk.outputs.dir "build"
  505. task run(dependsOn: buildSdk) << {
  506. ant.ant(dir: ".", antfile: "build.xml", target: "run")
  507. }
  508. task cleanSdk() <<{
  509. ant.ant(dir: ".", antfile: "build.xml", target: "clean")
  510. file("jme3-core-baselibs/release/").deleteDir()
  511. file("jme3-core-libraries/release/").deleteDir()
  512. file("jme3-core-baselibs/nbproject/project.xml").delete()
  513. file("jme3-core-libraries/nbproject/project.xml").delete()
  514. file("jme3-project-baselibs/release/").deleteDir()
  515. file("jme3-project-libraries/release/").deleteDir()
  516. file("jme3-project-testdata/release/").deleteDir()
  517. file("JME3TestsTemplate/src/jme3test/").deleteDir()
  518. file("JME3TestsTemplateAndroid/src/jme3test/").deleteDir()
  519. }
  520. task extractPlatformIndependent(type: Copy) {
  521. from zipTree('dist/jmonkeyplatform.zip')
  522. into "dist/temp/"
  523. exclude("jmonkeyplatform/etc/jmonkeyplatform.conf")
  524. }
  525. task patchPlatformIndependent(type: Copy, dependsOn: extractPlatformIndependent) {
  526. from zipTree('dist/jmonkeyplatform.zip')
  527. into "dist/temp/"
  528. include("jmonkeyplatform/etc/jmonkeyplatform.conf")
  529. filter { String line ->
  530. line.startsWith('jdkhome=') ? '#jdkhome="/path/to/jdk"': line
  531. }
  532. doLast {
  533. delete(file('dist/jmonkeyplatform.zip'))
  534. }
  535. }
  536. task fixPlatformIndependent(dependsOn: patchPlatformIndependent, type: Zip) {
  537. description = "We compile our installers with the bundled jdk, but the platform independent zip doesn't have the jdk. For this we need to change the jmonkeyplatform.zip after building the installers to not have a jdk bundled"
  538. from 'dist/temp'
  539. archiveName = 'jmonkeyplatform.zip'
  540. destinationDir = file('dist')
  541. doLast {
  542. delete("dist/temp")
  543. }
  544. }
  545. //jar.dependsOn(buildSdk)
  546. //clean.dependsOn(cleanSdk)