build.gradle 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 (!project.name.equals('jme3-testdata')) {
  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, description: 'Builds and copies the engine binaries, sources and javadoc to build/libDist') {
  28. doLast {
  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. }
  59. task createZipDistribution(type:Zip,dependsOn:["dist","libDist"], description:"Package the nightly zip distribution"){
  60. archiveName "jME" + jmeFullVersion + ".zip"
  61. into("/") {
  62. from {"./dist"}
  63. }
  64. into("/sources") {
  65. from {"$buildDir/libDist/sources"}
  66. }
  67. }
  68. task copyLibs(type: Copy){
  69. // description 'Copies the engine dependencies to build/libDist'
  70. from {
  71. subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
  72. }
  73. into "$buildDir/libDist/lib-ext" //buildDir.path + '/' + libsDirName + '/lib'
  74. }
  75. task dist(dependsOn: [':jme3-examples:dist', 'mergedJavadoc']){
  76. description 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
  77. }
  78. task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') {
  79. title = 'jMonkeyEngine3'
  80. destinationDir = mkdir("dist/javadoc")
  81. options.encoding = 'UTF-8'
  82. // Allows Javadoc to be generated on Java 8 despite doclint errors.
  83. if (JavaVersion.current().isJava8Compatible()) {
  84. options.addStringOption('Xdoclint:none', '-quiet')
  85. }
  86. options.overview = file("javadoc-overview.html")
  87. // Note: The closures below are executed lazily.
  88. source subprojects.collect {project ->
  89. project.sourceSets*.allJava
  90. }
  91. // classpath = files(subprojects.collect {project ->
  92. // project.sourceSets*.compileClasspath})
  93. // source {
  94. // subprojects*.sourceSets*.main*.allSource
  95. // }
  96. classpath.from {
  97. subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
  98. }
  99. }
  100. task mergedSource(type: Copy){
  101. }
  102. task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') {
  103. gradleVersion = '3.2.1'
  104. }
  105. ext {
  106. ndkCommandPath = ""
  107. ndkExists = false
  108. }
  109. task configureAndroidNDK {
  110. def ndkBuildFile = "ndk-build"
  111. // if windows, use ndk-build.cmd instead
  112. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  113. ndkBuildFile = "ndk-build.cmd"
  114. }
  115. // ndkPath is defined in the root project gradle.properties file
  116. String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
  117. //Use the environment variable for the NDK location if defined
  118. if (System.env.ANDROID_NDK != null) {
  119. ndkBuildPath = System.env.ANDROID_NDK + File.separator + ndkBuildFile
  120. }
  121. if (new File(ndkBuildPath).exists()) {
  122. ndkExists = true
  123. ndkCommandPath = ndkBuildPath
  124. }
  125. }
  126. //class IncrementalReverseTask extends DefaultTask {
  127. // @InputDirectory
  128. // def File inputDir
  129. //
  130. // @OutputDirectory
  131. // def File outputDir
  132. //
  133. // @Input
  134. // def inputProperty
  135. //
  136. // @TaskAction
  137. // void execute(IncrementalTaskInputs inputs) {
  138. // println inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
  139. // inputs.outOfDate { change ->
  140. // println "out of date: ${change.file.name}"
  141. // def targetFile = new File(outputDir, change.file.name)
  142. // targetFile.text = change.file.text.reverse()
  143. // }
  144. //
  145. // inputs.removed { change ->
  146. // println "removed: ${change.file.name}"
  147. // def targetFile = new File(outputDir, change.file.name)
  148. // targetFile.delete()
  149. // }
  150. // }
  151. //}
  152. //allprojects {
  153. // tasks.withType(JavaExec) {
  154. // enableAssertions = true // false by default
  155. // }
  156. // tasks.withType(Test) {
  157. // enableAssertions = true // true by default
  158. // }
  159. //}