build.gradle 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import org.gradle.api.artifacts.*
  2. apply plugin: 'base' // To add "clean" task to the root project.
  3. //apply plugin: 'java-library-distribution'
  4. // This is applied to all sub projects
  5. subprojects {
  6. // Don't add to native builds
  7. // if(!project.name.endsWith('native')){
  8. apply from: rootProject.file('common.gradle')
  9. // }
  10. }
  11. task run(dependsOn: ':jme3-examples:run') {
  12. description = 'Run the jME3 examples'
  13. }
  14. defaultTasks 'run'
  15. task libDist(dependsOn: subprojects.build) << {
  16. // description 'Builds and copies the engine binaries, sources and javadoc to build/libDist'
  17. File libFolder = mkdir("$buildDir/libDist/lib")
  18. File sourceFolder = mkdir("$buildDir/libDist/sources")
  19. File javadocFolder = mkdir("$buildDir/libDist/javadoc")
  20. subprojects.each {project ->
  21. if(project.ext.mainClass == ''){
  22. project.tasks.withType(Jar).each {archiveTask ->
  23. if(archiveTask.classifier == "sources"){
  24. copy {
  25. from archiveTask.archivePath
  26. into sourceFolder
  27. rename {project.name + '-' + archiveTask.classifier +'.'+ archiveTask.extension}
  28. }
  29. } else if(archiveTask.classifier == "javadoc"){
  30. copy {
  31. from archiveTask.archivePath
  32. into javadocFolder
  33. rename {project.name + '-' + archiveTask.classifier +'.'+ archiveTask.extension}
  34. }
  35. } else{
  36. copy {
  37. from archiveTask.archivePath
  38. into libFolder
  39. rename {project.name + '.' + archiveTask.extension}
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. task createZipDistribution(type:Zip,dependsOn:["dist","libDist"], description:"Package the nightly zip distribution"){
  47. archiveName "jME"+jmeVersion+"_"+jmeVersionTag+"_"+new Date().format("yyyy-MM-dd")+".zip"
  48. into("/") {
  49. from {"./dist"}
  50. }
  51. into("/sources") {
  52. from {"$buildDir/libDist/sources"}
  53. }
  54. }
  55. task copyLibs(type: Copy){
  56. // description 'Copies the engine dependencies to build/libDist'
  57. from {
  58. subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
  59. }
  60. into "$buildDir/libDist/lib-ext" //buildDir.path + '/' + libsDirName + '/lib'
  61. }
  62. task dist(dependsOn: [':jme3-examples:dist', 'mergedJavadoc']){
  63. description 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
  64. }
  65. task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') {
  66. title = 'jMonkeyEngine3'
  67. destinationDir = mkdir("dist/javadoc")
  68. // Allows Javadoc to be generated on Java 8 despite doclint errors.
  69. if (JavaVersion.current().isJava8Compatible()) {
  70. options.addStringOption('Xdoclint:none', '-quiet')
  71. }
  72. options.overview = file("javadoc-overview.html")
  73. // Note: The closures below are executed lazily.
  74. source subprojects.collect {project ->
  75. project.sourceSets*.allJava
  76. }
  77. // classpath = files(subprojects.collect {project ->
  78. // project.sourceSets*.compileClasspath})
  79. // source {
  80. // subprojects*.sourceSets*.main*.allSource
  81. // }
  82. classpath.from {
  83. subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
  84. }
  85. }
  86. task mergedSource(type: Copy){
  87. }
  88. task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') {
  89. gradleVersion = '2.2.1'
  90. }
  91. String findNDK() {
  92. def ndkBuildFile = "ndk-build"
  93. // if windows, use ndk-build.cmd instead
  94. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  95. ndkBuildFile = "ndk-build.cmd"
  96. }
  97. // ndkPath is defined in the root project gradle.properties file
  98. String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
  99. //Use the environment variable for the NDK location if defined
  100. if (System.env.ANDROID_NDK != null) {
  101. ndkBuildPath = System.env.ANDROID_NDK + File.separator + ndkBuildFile
  102. }
  103. if (new File(ndkBuildPath).exists()) {
  104. return ndkBuildPath
  105. } else {
  106. return null
  107. }
  108. }
  109. boolean checkNdkExists(String ndkCommandPath) {
  110. // String ndkCommandPath = findNDK()
  111. if (ndkCommandPath != null && new File(ndkCommandPath).exists()) {
  112. return true
  113. } else {
  114. return false
  115. }
  116. }
  117. ext {
  118. ndkCommandPath = findNDK()
  119. ndkExists = checkNdkExists(ndkCommandPath)
  120. }
  121. //class IncrementalReverseTask extends DefaultTask {
  122. // @InputDirectory
  123. // def File inputDir
  124. //
  125. // @OutputDirectory
  126. // def File outputDir
  127. //
  128. // @Input
  129. // def inputProperty
  130. //
  131. // @TaskAction
  132. // void execute(IncrementalTaskInputs inputs) {
  133. // println inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
  134. // inputs.outOfDate { change ->
  135. // println "out of date: ${change.file.name}"
  136. // def targetFile = new File(outputDir, change.file.name)
  137. // targetFile.text = change.file.text.reverse()
  138. // }
  139. //
  140. // inputs.removed { change ->
  141. // println "removed: ${change.file.name}"
  142. // def targetFile = new File(outputDir, change.file.name)
  143. // targetFile.delete()
  144. // }
  145. // }
  146. //}
  147. allprojects {
  148. tasks.withType(JavaExec) {
  149. enableAssertions = true // false by default
  150. }
  151. tasks.withType(Test) {
  152. enableAssertions = true // true by default
  153. }
  154. }