build.gradle 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. // Note: The closures below are executed lazily.
  73. source subprojects.collect {project ->
  74. project.sourceSets*.allJava
  75. }
  76. // classpath = files(subprojects.collect {project ->
  77. // project.sourceSets*.compileClasspath})
  78. // source {
  79. // subprojects*.sourceSets*.main*.allSource
  80. // }
  81. classpath.from {
  82. subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
  83. }
  84. }
  85. task mergedSource(type: Copy){
  86. }
  87. task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') {
  88. gradleVersion = '2.2.1'
  89. }
  90. String findNDK() {
  91. def ndkBuildFile = "ndk-build"
  92. // if windows, use ndk-build.cmd instead
  93. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  94. ndkBuildFile = "ndk-build.cmd"
  95. }
  96. // ndkPath is defined in the root project gradle.properties file
  97. String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
  98. //Use the environment variable for the NDK location if defined
  99. if (System.env.ANDROID_NDK != null) {
  100. ndkBuildPath = System.env.ANDROID_NDK + File.separator + ndkBuildFile
  101. }
  102. if (new File(ndkBuildPath).exists()) {
  103. return ndkBuildPath
  104. } else {
  105. return null
  106. }
  107. }
  108. boolean checkNdkExists(String ndkCommandPath) {
  109. // String ndkCommandPath = findNDK()
  110. if (ndkCommandPath != null && new File(ndkCommandPath).exists()) {
  111. return true
  112. } else {
  113. return false
  114. }
  115. }
  116. ext {
  117. ndkCommandPath = findNDK()
  118. ndkExists = checkNdkExists(ndkCommandPath)
  119. }
  120. //class IncrementalReverseTask extends DefaultTask {
  121. // @InputDirectory
  122. // def File inputDir
  123. //
  124. // @OutputDirectory
  125. // def File outputDir
  126. //
  127. // @Input
  128. // def inputProperty
  129. //
  130. // @TaskAction
  131. // void execute(IncrementalTaskInputs inputs) {
  132. // println inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
  133. // inputs.outOfDate { change ->
  134. // println "out of date: ${change.file.name}"
  135. // def targetFile = new File(outputDir, change.file.name)
  136. // targetFile.text = change.file.text.reverse()
  137. // }
  138. //
  139. // inputs.removed { change ->
  140. // println "removed: ${change.file.name}"
  141. // def targetFile = new File(outputDir, change.file.name)
  142. // targetFile.delete()
  143. // }
  144. // }
  145. //}