2
0

build.gradle 5.7 KB

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