build.gradle 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import org.gradle.api.artifacts.*
  2. buildscript {
  3. repositories {
  4. mavenCentral()
  5. }
  6. dependencies {
  7. classpath 'com.android.tools.build:gradle:1.1.0'
  8. }
  9. }
  10. apply plugin: 'base'
  11. // This is applied to all sub projects
  12. subprojects {
  13. if(!project.name.equals('jme3-android-examples')) {
  14. apply from: rootProject.file('common.gradle')
  15. } else {
  16. apply from: rootProject.file('common-android-app.gradle')
  17. }
  18. }
  19. task run(dependsOn: ':jme3-examples:run') {
  20. description = 'Run the jME3 examples'
  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. }
  63. task copyLibs(type: Copy){
  64. // description 'Copies the engine dependencies to build/libDist'
  65. from {
  66. subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
  67. }
  68. into "$buildDir/libDist/lib-ext" //buildDir.path + '/' + libsDirName + '/lib'
  69. }
  70. task dist(dependsOn: [':jme3-examples:dist', 'mergedJavadoc']){
  71. description 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
  72. }
  73. task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') {
  74. title = 'jMonkeyEngine3'
  75. destinationDir = mkdir("dist/javadoc")
  76. // Allows Javadoc to be generated on Java 8 despite doclint errors.
  77. if (JavaVersion.current().isJava8Compatible()) {
  78. options.addStringOption('Xdoclint:none', '-quiet')
  79. }
  80. options.overview = file("javadoc-overview.html")
  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 = '2.2.1'
  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. //}
  155. //allprojects {
  156. // tasks.withType(JavaExec) {
  157. // enableAssertions = true // false by default
  158. // }
  159. // tasks.withType(Test) {
  160. // enableAssertions = true // true by default
  161. // }
  162. //}