From 471498890025297d57a75766d700cc64a6f8dab3 Mon Sep 17 00:00:00 2001 From: Distopico Vegan Date: Wed, 5 Dec 2018 22:21:48 -0500 Subject: [PATCH] chore: add jdee config --- .gitignore | 1 + app/build.gradle | 12 ++-- build.gradle | 1 - jdee.gradle | 150 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 jdee.gradle diff --git a/.gitignore b/.gitignore index e2519b5b..c08bf69b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ proguard/ # IDE and OS files .idea/ *.iml +*.el .DS_Store .externalNativeBuild \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 97f8ab58..cd1c5332 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.application' -apply plugin: 'changelog' +apply from: "${rootDir}/jdee.gradle" android { compileSdkVersion 28 @@ -51,10 +51,6 @@ android { } } -changelog { - versionNum "v$android.defaultConfig.versionName" -} - repositories { google() jcenter() @@ -63,6 +59,10 @@ repositories { } } +configurations { + implementationDeps.extendsFrom implementation +} + dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) @@ -120,5 +120,5 @@ dependencies { implementation "org.sufficientlysecure:openpgp-api:$openpgp_version" // https://android.googlesource.com/platform/frameworks/opt/colorpicker - implementation project(path: ':colorpicker') + implementation project(path: ':colorpicker', configuration: 'default') } diff --git a/build.gradle b/build.gradle index 7aa00853..c3b765fa 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,6 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' - classpath 'com.github.marcpoppleton:git-changelog:0.1.3' } } diff --git a/jdee.gradle b/jdee.gradle new file mode 100644 index 00000000..d48d39b8 --- /dev/null +++ b/jdee.gradle @@ -0,0 +1,150 @@ +// +// Gradle task that creates the JDEE project file to andorid +// + +import static groovy.io.FileType.FILES + +def jarFiles = { project -> + def folder = new File("${project.buildDir}/intermediates") + def files = [] + + if( folder.exists() ) { + // if exist look for jars + folder.eachFileRecurse(FILES) { + if(it.name.endsWith('.jar')) { + files << it.getAbsolutePath() + } + } + } + files +} + +def getImplementation = { project -> + def files = [] + def transforms = [] + + // get dependencies jars + project.configurations.implementationDeps.each { dep -> + if(dep.name.endsWith('.jar')) { + files << dep.getAbsolutePath() + } else { + // get jar from aar + def cacheFolder = new File("${System.getProperty('user.home')}/.gradle/caches") + + if( cacheFolder.exists() ) { + cacheFolder.eachFileRecurse(FILES) { + if(!transforms.contains(dep.name) && it.path.contains(dep.name) && + it.name.endsWith('.jar')) { + transforms << dep.name + files << it.getAbsolutePath() + } + } + } + } + } + + files +} + +def generatedDirs = { project -> + def folder = new File("${project.buildDir}/generated") + def dirs = [] + + if( folder.exists() ) { + folder.eachDirRecurse { dir -> + if (!(dir ==~ /.*generated\/res\/.*/)) { + dirs << dir + } + } + } + dirs +} + +def prj = { project -> + "(jdee-project-file-version" (["1.0"]) + "(jdee-set-variables" { + "'(jdee-compile-option-directory" (["${project.buildDir}"]) + "'(jdee-junit-working-directory" ([]) + + "'(jdee-compile-option-source" { + "'(" (["default", "${project.targetCompatibility}"]) + } + + "'(jdee-compile-option-target" { + "'(" (["default", "${project.sourceCompatibility}"]) + } + + "'(jdee-sourcepath" { + "'(" ( + ["${project.projectDir}/src/androidTest/java"] + + project.android.sourceSets.main.java.srcDirs + + android.sourceSets.test.java.srcDirs + + project.android.sourceSets.test.java.srcDirs + + project.android.sourceSets.main.assets.srcDirs + + project.android.sourceSets.main.renderscript.srcDirs + + project.android.sourceSets.main.res.srcDirs + + project.android.sourceSets.main.aidl.srcDirs + + project.android.sourceSets.main.jniLibs.srcDirs + + project.android.sourceSets.main.resources.srcDirs + + (([] as Set) + generatedDirs(project)) + ) + } + + "'(jdee-global-classpath" { + "'(" ( + ["${project.buildDir}/intermediates/classes/debug", + "${project.buildDir}/intermediates/classes/test/debug"] + + android.getBootClasspath() + + configurations.archives.allArtifacts.getFiles() + + project.compileDebugJavaWithJavac.destinationDir + + project.compileReleaseJavaWithJavac.destinationDir + + (([] as Set) + project.configurations.compile.getFiles() + + project.configurations.testCompile.getFiles() + + getImplementation(project) + + jarFiles(project) + )) + } + } +} + +projects { + task("jdee") { + doLast { + def output = new File(project.projectDir, "prj.el").newPrintWriter() + output.print ';;\n' + output.print ';; This is a generated file.\n' + output.print ';; To recreate, run "`gradlew jdee` or `gradlew assemble jdee`".\n' + output.print ';;\n' + try { + prj.delegate = new NodeBuilder() { + def lev = 0 + + def write = { Object file -> + output.print '\n' + ''.padRight(lev, ' ') + "\"${file}\"".tr('\\', '/') + } + + Object createNode(Object name) { + output.print '\n' + ''.padRight(lev++, ' ') + name + return name + } + + Object createNode(Object name, Object value) { + createNode(name) + value.each write + return name + } + + void nodeCompleted(Object parent, Object child) { + output.print ")" + lev-- + } + } + + prj(project) + output.close() + } finally { + output.flush() + } + } + } +} \ No newline at end of file