Last active
March 4, 2021 10:11
-
-
Save iyxan23/d34461ef878eb7b0e4114e84fdae55c8 to your computer and use it in GitHub Desktop.
Gradle build script used to build a java project into a jar file and dexify it using d8
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
plugins { | |
id "de.undercouch.download" version "4.1.1" | |
} | |
apply plugin: 'java' | |
group 'com.example.module' | |
version '1.0' | |
repositories { | |
mavenCentral() | |
} | |
task buildDexJar(dependsOn:jar) { | |
doLast { | |
if (!new File(buildDir, "d8.jar").exists()) { | |
println "Downloading d8... (one time only)" | |
download { | |
src 'https://download1587.mediafire.com/v03pxj2159hg/n3pnyus4cxqjsaq/d8.jar' | |
dest buildDir | |
} | |
} | |
javaexec { | |
group = "Execution" | |
description = "Run d8 to dexify the generated JAR file" | |
classpath = files(new File(buildDir, "d8.jar")) | |
main = "com.android.tools.r8.D8" | |
args = ['--output', 'output.jar', '--min-api', '21', jar.archiveFile.get().asFile.path] | |
} | |
} | |
} | |
dependencies { | |
implementation 'de.undercouch:gradle-download-task:4.1.1' | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment