Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.7 KiB

  1. //
  2. // Gradle task that creates the JDEE project file to andorid
  3. //
  4. import static groovy.io.FileType.FILES
  5. def jarFiles = { project ->
  6. def folder = new File("${project.buildDir}/intermediates")
  7. def files = []
  8. if( folder.exists() ) {
  9. // if exist look for jars
  10. folder.eachFileRecurse(FILES) {
  11. if(it.name.endsWith('.jar')) {
  12. files << it.getAbsolutePath()
  13. }
  14. }
  15. }
  16. files
  17. }
  18. def getImplementation = { project ->
  19. def files = []
  20. def transforms = []
  21. // get dependencies jars
  22. project.configurations.implementationDeps.each { dep ->
  23. if(dep.name.endsWith('.jar')) {
  24. files << dep.getAbsolutePath()
  25. } else {
  26. // get jar from aar
  27. def cacheFolder = new File("${System.getProperty('user.home')}/.gradle/caches")
  28. if( cacheFolder.exists() ) {
  29. cacheFolder.eachFileRecurse(FILES) {
  30. if(!transforms.contains(dep.name) && it.path.contains(dep.name) &&
  31. it.name.endsWith('.jar')) {
  32. transforms << dep.name
  33. files << it.getAbsolutePath()
  34. }
  35. }
  36. }
  37. }
  38. }
  39. files
  40. }
  41. def generatedDirs = { project ->
  42. def folder = new File("${project.buildDir}/generated")
  43. def dirs = []
  44. if( folder.exists() ) {
  45. folder.eachDirRecurse { dir ->
  46. if (!(dir ==~ /.*generated\/res\/.*/)) {
  47. dirs << dir
  48. }
  49. }
  50. }
  51. dirs
  52. }
  53. def prj = { project ->
  54. "(jdee-project-file-version" (["1.0"])
  55. "(jdee-set-variables" {
  56. "'(jdee-compile-option-directory" (["${project.buildDir}"])
  57. "'(jdee-junit-working-directory" ([])
  58. "'(jdee-compile-option-source" {
  59. "'(" (["default", "${project.targetCompatibility}"])
  60. }
  61. "'(jdee-compile-option-target" {
  62. "'(" (["default", "${project.sourceCompatibility}"])
  63. }
  64. "'(jdee-sourcepath" {
  65. "'(" (
  66. ["${project.projectDir}/src/androidTest/java"]
  67. + project.android.sourceSets.main.java.srcDirs
  68. + android.sourceSets.test.java.srcDirs
  69. + project.android.sourceSets.test.java.srcDirs
  70. + project.android.sourceSets.main.assets.srcDirs
  71. + project.android.sourceSets.main.renderscript.srcDirs
  72. + project.android.sourceSets.main.res.srcDirs
  73. + project.android.sourceSets.main.aidl.srcDirs
  74. + project.android.sourceSets.main.jniLibs.srcDirs
  75. + project.android.sourceSets.main.resources.srcDirs
  76. + (([] as Set) + generatedDirs(project))
  77. )
  78. }
  79. "'(jdee-global-classpath" {
  80. "'(" (
  81. ["${project.buildDir}/intermediates/classes/debug",
  82. "${project.buildDir}/intermediates/classes/test/debug"]
  83. + android.getBootClasspath()
  84. + configurations.archives.allArtifacts.getFiles()
  85. + project.compileDebugJavaWithJavac.destinationDir
  86. + project.compileReleaseJavaWithJavac.destinationDir
  87. + (([] as Set) + project.configurations.compile.getFiles()
  88. + project.configurations.testCompile.getFiles()
  89. + getImplementation(project)
  90. + jarFiles(project)
  91. ))
  92. }
  93. }
  94. }
  95. projects {
  96. task("jdee") {
  97. doLast {
  98. def output = new File(project.projectDir, "prj.el").newPrintWriter()
  99. output.print ';;\n'
  100. output.print ';; This is a generated file.\n'
  101. output.print ';; To recreate, run "`gradlew jdee` or `gradlew assemble jdee`".\n'
  102. output.print ';;\n'
  103. try {
  104. prj.delegate = new NodeBuilder() {
  105. def lev = 0
  106. def write = { Object file ->
  107. output.print '\n' + ''.padRight(lev, ' ') + "\"${file}\"".tr('\\', '/')
  108. }
  109. Object createNode(Object name) {
  110. output.print '\n' + ''.padRight(lev++, ' ') + name
  111. return name
  112. }
  113. Object createNode(Object name, Object value) {
  114. createNode(name)
  115. value.each write
  116. return name
  117. }
  118. void nodeCompleted(Object parent, Object child) {
  119. output.print ")"
  120. lev--
  121. }
  122. }
  123. prj(project)
  124. output.close()
  125. } finally {
  126. output.flush()
  127. }
  128. }
  129. }
  130. }