build.gradle 5.5 KB

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