build.gradle 26 KB

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