build.gradle 5.4 KB

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