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