Last active
December 17, 2015 17:59
-
-
Save totallyunknown/5649764 to your computer and use it in GitHub Desktop.
I'm trying to migrate from a ant build.xml from a small android library to a gradle.build file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Tested with: | |
* MacOS X 10.8 | |
* Gradle 1.6 | |
* Sonar 3.5.1 | |
* Proguard 4.9 (4.10beta is working as well, but is not available at MavenCentral | |
* Sonatype Nexus 2.1.2 | |
*/ | |
version = '1.1.0-SNAPSHOT' | |
apply plugin: 'java' | |
apply plugin: "sonar-runner" | |
apply plugin: "maven" | |
defaultTasks 'clean', 'build', 'proguard' | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath "net.sf.proguard:proguard-gradle:4.9" | |
} | |
} | |
jar { | |
baseName = 'library-android-sdk' | |
project.group = 'com.company.android' | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'ch.acra:acra:4.2.3' | |
compile 'org.slf4j:slf4j-api:1.7.1' | |
compile 'com.github.tony19:logback-android-core:1.0.7-1' | |
compile 'com.github.tony19:logback-android-classic:1.0.7-1' | |
compile 'com.google.android:android:2.2.1' // SDK version 8 | |
//compile 'com.google.android:support-v4:r7' | |
compile fileTree(dir: 'libs', include: [ | |
'gcm.jar', | |
'android-support-v4.jar']) | |
} | |
sourceSets { | |
main { | |
java.srcDirs = ['src'] | |
} | |
} | |
// to use it, run gradle build -Pxlint | |
if (hasProperty("xlint")) { | |
tasks.withType(Compile) { | |
options.compilerArgs << "-Xlint:unchecked" | |
} | |
} | |
// run with gradle sonarRunner -Dsonar.jdbc.password=foo | |
sonarRunner { | |
sonarProperties { | |
property "sonar.host.url", "https://example.org/sonar/" | |
property "sonar.jdbc.url", "jdbc:mysql://example.org/sonar" | |
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver" | |
property "sonar.jdbc.username", "sonar" | |
property "sonar.language", "java" | |
} | |
} | |
uploadArchives { | |
repositories.mavenDeployer { | |
configureAuth = { | |
authentication(userName: 'admin', password: 'admin123') | |
} | |
snapshotRepository(url: "https://example.org/nexus/content/repositories/snapshots/", configureAuth) | |
repository(url: "https://example.org/nexus/content/repositories/releases/", configureAuth) | |
} | |
} | |
task proguard(type: proguard.gradle.ProGuardTask) { | |
configuration 'proguard/configuration.pro' | |
String outMapPath = new File(project.libsDir, jar.baseName + "-" + version + ".map") | |
printmapping outMapPath | |
// include all SDK jars | |
proguard.injars(jar.archivePath) | |
// include all library jars | |
for (String runtimeJar : configurations.runtime) { | |
proguard.libraryjars(runtimeJar) | |
} | |
proguard.libraryjars "${System.getProperty('java.home')}/../Classes/classes.jar" | |
String outJarFilePath = new File(project.libsDir, jar.baseName + "-" + version + "-proguarded.jar") | |
proguard.outjars(outJarFilePath) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment