2
0

build.gradle 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import org.gradle.api.artifacts.*
  2. buildscript {
  3. repositories {
  4. jcenter()
  5. }
  6. dependencies {
  7. classpath 'com.android.tools.build:gradle:1.1.0'
  8. classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
  9. }
  10. }
  11. apply plugin: 'base'
  12. apply from: file('version.gradle')
  13. apply from: file('upload.gradle')
  14. // This is applied to all sub projects
  15. subprojects {
  16. if(!project.name.equals('jme3-android-examples')) {
  17. apply from: rootProject.file('common.gradle')
  18. if (!['jme3-testdata', 'sdk'].contains(project.name)) {
  19. apply from: rootProject.file('bintray.gradle')
  20. }
  21. } else {
  22. apply from: rootProject.file('common-android-app.gradle')
  23. }
  24. }
  25. task run(dependsOn: ':jme3-examples:run') {
  26. description = 'Run the jME3 examples'
  27. }
  28. defaultTasks 'run'
  29. task libDist(dependsOn: subprojects.build) << {
  30. // description 'Builds and copies the engine binaries, sources and javadoc to build/libDist'
  31. File libFolder = mkdir("$buildDir/libDist/lib")
  32. File sourceFolder = mkdir("$buildDir/libDist/sources")
  33. File javadocFolder = mkdir("$buildDir/libDist/javadoc")
  34. subprojects.each {project ->
  35. if(project.ext.mainClass == ''){
  36. project.tasks.withType(Jar).each {archiveTask ->
  37. if(archiveTask.classifier == "sources"){
  38. copy {
  39. from archiveTask.archivePath
  40. into sourceFolder
  41. rename {project.name + '-' + archiveTask.classifier +'.'+ archiveTask.extension}
  42. }
  43. } else if(archiveTask.classifier == "javadoc"){
  44. copy {
  45. from archiveTask.archivePath
  46. into javadocFolder
  47. rename {project.name + '-' + archiveTask.classifier +'.'+ archiveTask.extension}
  48. }
  49. } else{
  50. copy {
  51. from archiveTask.archivePath
  52. into libFolder
  53. rename {project.name + '.' + archiveTask.extension}
  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. task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') {
  104. gradleVersion = '2.2.1'
  105. }
  106. ext {
  107. ndkCommandPath = ""
  108. ndkExists = false
  109. }
  110. task configureAndroidNDK {
  111. def ndkBuildFile = "ndk-build"
  112. // if windows, use ndk-build.cmd instead
  113. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  114. ndkBuildFile = "ndk-build.cmd"
  115. }
  116. // ndkPath is defined in the root project gradle.properties file
  117. String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
  118. //Use the environment variable for the NDK location if defined
  119. if (System.env.ANDROID_NDK != null) {
  120. ndkBuildPath = System.env.ANDROID_NDK + File.separator + ndkBuildFile
  121. }
  122. if (new File(ndkBuildPath).exists()) {
  123. ndkExists = true
  124. ndkCommandPath = ndkBuildPath
  125. }
  126. }
  127. //class IncrementalReverseTask extends DefaultTask {
  128. // @InputDirectory
  129. // def File inputDir
  130. //
  131. // @OutputDirectory
  132. // def File outputDir
  133. //
  134. // @Input
  135. // def inputProperty
  136. //
  137. // @TaskAction
  138. // void execute(IncrementalTaskInputs inputs) {
  139. // println inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
  140. // inputs.outOfDate { change ->
  141. // println "out of date: ${change.file.name}"
  142. // def targetFile = new File(outputDir, change.file.name)
  143. // targetFile.text = change.file.text.reverse()
  144. // }
  145. //
  146. // inputs.removed { change ->
  147. // println "removed: ${change.file.name}"
  148. // def targetFile = new File(outputDir, change.file.name)
  149. // targetFile.delete()
  150. // }
  151. // }
  152. //}
  153. //allprojects {
  154. // tasks.withType(JavaExec) {
  155. // enableAssertions = true // false by default
  156. // }
  157. // tasks.withType(Test) {
  158. // enableAssertions = true // true by default
  159. // }
  160. //}