build.gradle 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. //class IncrementalReverseTask extends DefaultTask {
  86. // @InputDirectory
  87. // def File inputDir
  88. //
  89. // @OutputDirectory
  90. // def File outputDir
  91. //
  92. // @Input
  93. // def inputProperty
  94. //
  95. // @TaskAction
  96. // void execute(IncrementalTaskInputs inputs) {
  97. // println inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
  98. // inputs.outOfDate { change ->
  99. // println "out of date: ${change.file.name}"
  100. // def targetFile = new File(outputDir, change.file.name)
  101. // targetFile.text = change.file.text.reverse()
  102. // }
  103. //
  104. // inputs.removed { change ->
  105. // println "removed: ${change.file.name}"
  106. // def targetFile = new File(outputDir, change.file.name)
  107. // targetFile.delete()
  108. // }
  109. // }
  110. //}