build.gradle 5.7 KB

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