diff --git a/build.gradle b/build.gradle index 45c6d8d1d..d6d339908 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,8 @@ +apply plugin: 'idea' + +version = '0.8.0' +def jarVersion = version + buildscript { repositories { mavenCentral() @@ -18,17 +23,39 @@ allprojects { apply plugin: 'jacoco' apply plugin: 'com.github.kt3k.coveralls' - apply plugin: 'idea' } subprojects { - group = 'org.cf' - apply plugin: 'java' - sourceCompatibility = 1.7 apply plugin: 'eclipse' + apply plugin: 'idea' apply plugin: 'com.github.johnrengelman.shadow' + group = 'org.cf' + sourceCompatibility = 1.7 + version = parent.version + + jar { + version = jarVersion + } + + ext { + depends = [ + args4j: 'args4j:args4j:2.32', + commons_io: 'commons-io:commons-io:2.4', + commons_lang: 'org.apache.commons:commons-lang3:3.4', + findbugs: 'com.google.code.findbugs:jsr305:1.3.9', + guava: 'com.google.guava:guava:18.0', + junit: 'junit:junit:4.12', + mockito: 'org.mockito:mockito-core:1.10.19', + perfidix: 'org.perfidix:perfidix:3.6.9', + proguard_gradle: 'net.sf.proguard:proguard-gradle:5.2.1', + slf4j_api: 'org.slf4j:slf4j-api:1.7.12', + trove4j: 'net.sf.trove4j:trove4j:3.0.3', + ] + } + + // This is just to show off API usage. No tests needed. if (!project.name.equals("demoapp")) { jacocoTestReport { reports { diff --git a/simplify/build.gradle b/simplify/build.gradle index 6d92650d6..2a56ffa70 100644 --- a/simplify/build.gradle +++ b/simplify/build.gradle @@ -1,31 +1,79 @@ -project.version = '0.8.0' - -apply plugin: 'application' -mainClassName = 'org.cf.simplify.Main' +buildscript { + dependencies { + classpath depends.proguard_gradle + } + repositories { + mavenCentral() + } +} dependencies { compile project(':smalivm') // Lazy - compile 'commons-io:commons-io:2.4' - compile 'org.apache.commons:commons-lang3:3.4' + compile depends.commons_io + compile depends.commons_lang // CLI parsing - compile 'args4j:args4j:2.32' + compile depends.args4j // Primitive collections - compile 'net.sf.trove4j:trove4j:3.0.3' + compile depends.trove4j // Perfromance benchmarking - compile 'org.perfidix:perfidix:3.6.9' + compile depends.perfidix // Logging - compile 'org.slf4j:slf4j-api:1.7.12' + compile depends.slf4j_api compile 'ch.qos.logback:logback-core:1.1.3' compile 'ch.qos.logback:logback-classic:1.1.3' // Testing - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile depends.junit + testCompile depends.mockito testCompile project(path: ':smalivm', configuration: 'testArtifacts') } + +// Build a separate jar that contains all dependencies +task fatJar(type: Jar) { + from sourceSets.main.output + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + + manifest { + attributes('Main-Class': 'org.cf.simplify.Main') + } + + doLast { + if (!System.getProperty('os.name').toLowerCase().contains('windows')) { + ant.symlink(link: file("${destinationDir}/simplify.jar"), resource: archivePath, overwrite: true) + } + } +} +tasks.getByPath('build').dependsOn(fatJar) + +task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) { + def outFile = fatJar.destinationDir.getPath() + '/' + fatJar.baseName + '-' + fatJar.version + '-proguard' + '.' + fatJar.extension + + print fatJar.archivePath + injars fatJar.archivePath + outjars outFile + + libraryjars "${System.properties['java.home']}/lib/rt.jar" + + dontobfuscate + //dontoptimize + + keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }' + keepattributes '*Annotation*,Signature,InnerClasses,EnclosingMethod' + + keep 'public class org.cf.simplify.Main { public static void main(java.lang.String[]); }' + keep 'public class org.cf.simplify.Options { *; }' + keep 'public class android.util.** { *; }' + + keep 'class org.apache.commons.logging.** { public protected *; }' + keep 'public class org.kohsuke.args4j.** { public protected *; }' + keep 'public class ch.qos.** { public protected *; }' + + dontwarn + verbose +} diff --git a/smalivm/build.gradle b/smalivm/build.gradle index 4576acddc..d7675c596 100644 --- a/smalivm/build.gradle +++ b/smalivm/build.gradle @@ -1,19 +1,3 @@ -project.version = '0.8.0' - -task myTestsJar(type: Jar) { - // Simplify uses some classes from smalivm's tests. - classifier = 'tests' - from sourceSets.test.output -} - -configurations { - testArtifacts -} - -artifacts { - testArtifacts myTestsJar -} - dependencies { // Object cloning compile 'uk.com.robust-it:cloning:1.9.2' @@ -22,17 +6,17 @@ dependencies { compile 'commons-beanutils:commons-beanutils:1.9.2' // Lazy - compile 'commons-io:commons-io:2.4' - compile 'org.apache.commons:commons-lang3:3.4' + compile depends.commons_io + compile depends.commons_lang // Primitive collections - compile 'net.sf.trove4j:trove4j:3.0.3' + compile depends.trove4j // Perfromance benchmarking - compile 'org.perfidix:perfidix:3.6.9' + compile depends.perfidix // Logging facade - compile 'org.slf4j:slf4j-api:1.7.12' + compile depends.slf4j_api // Parsing and writing dex files compile 'org.smali:dexlib2:2.0.6' @@ -42,6 +26,20 @@ dependencies { // Contains Android framework classes that should be reflected instead of virtually executed compile files('libs/android-local.jar') - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile depends.junit + testCompile depends.mockito +} + +task myTestsJar(type: Jar) { + // Simplify uses some classes from smalivm's tests. + classifier = 'tests' + from sourceSets.test.output +} + +configurations { + testArtifacts +} + +artifacts { + testArtifacts myTestsJar }