Last active
August 29, 2015 14:03
-
-
Save bbergler/5f1b2219e4edcd1a836b to your computer and use it in GitHub Desktop.
workaround for android L preview okio packaging issue
This file contains hidden or 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
apply plugin: 'android-library' | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
} | |
configurations { | |
patch | |
} | |
android { | |
compileSdkVersion 19 | |
buildToolsVersion '19.1.0' | |
defaultConfig { | |
minSdkVersion 8 | |
targetSdkVersion 19 | |
versionCode 1 | |
versionName "1.0" //SDK Version is defined in the SDK lib module | |
} | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'com.squareup.retrofit:retrofit:1.6.0' | |
compile files('lib/okhttp-urlconnection-2.0.0.patched.jar') | |
// compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0' | |
compile 'javax.annotation:jsr250-api:1.0' | |
patch 'com.squareup.okio:okio:1.0.0' | |
patch 'com.googlecode.jarjar:jarjar:1.3' | |
patch 'com.squareup.okhttp:okhttp:2.0.0' | |
patch 'com.squareup.okhttp:okhttp-urlconnection:2.0.0' | |
} | |
project.ext.set("shouldBuildPatch", { !new File('lib/okhttp-urlconnection-2.0.0.patched.jar').exists() }) | |
task downloadPatchLibs(type: Copy) { | |
into('lib') | |
from(configurations.patch) | |
exclude('jarjar*') | |
duplicatesStrategy(DuplicatesStrategy.EXCLUDE) | |
} | |
downloadPatchLibs.doFirst { | |
if(!shouldBuildPatch()) { throw new StopExecutionException() } | |
} | |
task applyPatch(dependsOn: 'downloadPatchLibs') << { | |
if (shouldBuildPatch()) { | |
project.ant { | |
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", classpath: configurations.patch.asPath | |
jarjar(jarfile: 'lib/okhttp-urlconnection-2.0.0.patched.jar', filesetmanifest: "merge") { | |
zipfileset(src: 'lib/okio-1.0.0.jar') | |
zipfileset(src: 'lib/okhttp-2.0.0.jar') | |
zipfileset(src: 'lib/okhttp-urlconnection-2.0.0.jar') | |
rule pattern: "okio.**", result: "custom.okio.@1" | |
} | |
} | |
} | |
} | |
task cleanupDownloadPatchLibs(type: Delete, dependsOn: 'applyPatch') { | |
delete 'lib/okio-1.0.0.jar' | |
delete 'lib/okhttp-2.0.0.jar' | |
delete 'lib/okhttp-urlconnection-2.0.0.jar' | |
} | |
assemble.dependsOn(cleanupDownloadPatchLibs) | |
task cleanPatch(type: Delete) { | |
delete 'lib' | |
} | |
clean.dependsOn(cleanPatch) |
Great work! Very, very grateful for this, i do not know how it work but thank you)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great workaround, worked like a charm. But we couuld use
tasks.applyPatch.doLast{
cleanupDownloadPatchLibs
}
and so apply patch woundn't need to depend on cleanupDownloadPatchLibs