build.gradle 5.8 KB

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