build.gradle 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. // Note: The closures below are executed lazily.
  68. source subprojects.collect {project ->
  69. project.sourceSets*.allJava
  70. }
  71. // classpath = files(subprojects.collect {project ->
  72. // project.sourceSets*.compileClasspath})
  73. // source {
  74. // subprojects*.sourceSets*.main*.allSource
  75. // }
  76. classpath.from {
  77. subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
  78. }
  79. }
  80. task mergedSource(type: Copy){
  81. }
  82. task wrapper(type: Wrapper, description: 'Creates and deploys the Gradle wrapper to the current directory.') {
  83. gradleVersion = '1.11'
  84. }
  85. String findNDK() {
  86. def ndkBuildFile = "ndk-build"
  87. // if windows, use ndk-build.cmd instead
  88. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  89. ndkBuildFile = "ndk-build.cmd"
  90. }
  91. // ndkPath is defined in the root project gradle.properties file
  92. String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
  93. //Use the environment variable for the NDK location if defined
  94. if (System.env.ANDROID_NDK != null) {
  95. ndkBuildPath = System.env.ANDROID_NDK + File.separator + ndkBuildFile
  96. }
  97. if (new File(ndkBuildPath).exists()) {
  98. return ndkBuildPath
  99. } else {
  100. return null
  101. }
  102. }
  103. boolean checkNdkExists(String ndkCommandPath) {
  104. // String ndkCommandPath = findNDK()
  105. if (ndkCommandPath != null && new File(ndkCommandPath).exists()) {
  106. return true
  107. } else {
  108. return false
  109. }
  110. }
  111. ext {
  112. ndkCommandPath = findNDK()
  113. ndkExists = checkNdkExists(ndkCommandPath)
  114. }
  115. //class IncrementalReverseTask extends DefaultTask {
  116. // @InputDirectory
  117. // def File inputDir
  118. //
  119. // @OutputDirectory
  120. // def File outputDir
  121. //
  122. // @Input
  123. // def inputProperty
  124. //
  125. // @TaskAction
  126. // void execute(IncrementalTaskInputs inputs) {
  127. // println inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
  128. // inputs.outOfDate { change ->
  129. // println "out of date: ${change.file.name}"
  130. // def targetFile = new File(outputDir, change.file.name)
  131. // targetFile.text = change.file.text.reverse()
  132. // }
  133. //
  134. // inputs.removed { change ->
  135. // println "removed: ${change.file.name}"
  136. // def targetFile = new File(outputDir, change.file.name)
  137. // targetFile.delete()
  138. // }
  139. // }
  140. //}