build: syntax updates for gradle files

This commit is contained in:
Connor Tumbleson 2021-03-04 07:21:22 -05:00
parent 45c91ef5bf
commit e9a897febe
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75
3 changed files with 21 additions and 17 deletions

View File

@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import proguard.gradle.ProGuardTask
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
dependencies { dependencies {
@ -43,7 +45,7 @@ task cleanOutputDirectory(type: Delete) {
delete fileTree(dir: jar.getDestinationDirectory().getAsFile(), exclude: "apktool-cli-all.jar") delete fileTree(dir: jar.getDestinationDirectory().getAsFile(), exclude: "apktool-cli-all.jar")
} }
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: shadowJar) { task proguard(type: ProGuardTask, dependsOn: shadowJar) {
injars shadowJar.getArchiveFile() injars shadowJar.getArchiveFile()
// Java 9 and prior uses merged package for runtime, later uses split jmod files. // Java 9 and prior uses merged package for runtime, later uses split jmod files.

View File

@ -69,25 +69,25 @@ allprojects {
} }
if (!('release' in gradle.startParameter.taskNames)) { if (!('release' in gradle.startParameter.taskNames)) {
def hash = getCheckedOutGitCommitHash(); def hash = getCheckedOutGitCommitHash()
if (hash == null) { if (hash == null) {
project.ext.set("hash", "dirty") project.ext.set("hash", "dirty")
project.ext.set("apktool_version", apktoolversion_major + "-dirty") project.ext.set("apktool_version", apktoolversion_major + "-dirty")
println "Building SNAPSHOT (no .git folder found)"; println "Building SNAPSHOT (no .git folder found)"
} else { } else {
project.ext.set("hash", hash); project.ext.set("hash", hash)
project.ext.set("apktool_version", apktoolversion_major + "-" + hash + "-SNAPSHOT"); project.ext.set("apktool_version", apktoolversion_major + "-" + hash + "-SNAPSHOT")
println "Building SNAPSHOT (" + getCheckedOutBranch() + "): " + hash; println "Building SNAPSHOT (" + getCheckedOutBranch() + "): " + hash
} }
} else { } else {
project.ext.set("hash", "") project.ext.set("hash", "")
if (apktoolversion_minor.length() > 0) { if (apktoolversion_minor.length() > 0) {
project.ext.set("apktool_version", apktoolversion_major + "-" + apktoolversion_minor); project.ext.set("apktool_version", apktoolversion_major + "-" + apktoolversion_minor)
} else { } else {
project.ext.set("apktool_version", apktoolversion_major); project.ext.set("apktool_version", apktoolversion_major)
} }
println "Building RELEASE (" + getCheckedOutBranch() + "): " + project.ext.apktool_version; println "Building RELEASE (" + getCheckedOutBranch() + "): " + project.ext.apktool_version
} }
build.doFirst { build.doFirst {
@ -99,7 +99,7 @@ build.doFirst {
"We found a " + javaVersion + " JDK\n" + "We found a " + javaVersion + " JDK\n" +
"Please update JAVA_HOME to use at least a 1.8 JDK\n" + "Please update JAVA_HOME to use at least a 1.8 JDK\n" +
"Currently it is set to: " + System.getProperty("java.home") "Currently it is set to: " + System.getProperty("java.home")
); )
} }
} }

View File

@ -1,3 +1,5 @@
import org.codehaus.groovy.runtime.MethodClosure
/** /**
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com> * Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
* *
@ -21,8 +23,8 @@ def getCheckedOutGitCommitHash() {
def head def head
try { try {
head = new File(gitFolder + "HEAD").text.split(":") head = new File(gitFolder + "HEAD").text.split(":")
} catch(Exception e) { } catch(Exception ignored) {
return null; return null
} }
def isCommit = head.length == 1 def isCommit = head.length == 1
@ -38,13 +40,13 @@ def getCheckedOutBranch() {
def head def head
try { try {
head = new File(gitFolder + "HEAD").text.split("/") head = new File(gitFolder + "HEAD").text.split("/")
return head[2].trim(); return head[2].trim()
} catch(Exception e) { } catch(Exception ignored) {
return "SNAPSHOT"; return "SNAPSHOT"
} }
} }
ext { ext {
getCheckedOutGitCommitHash = this.&getCheckedOutGitCommitHash getCheckedOutGitCommitHash = this.&getCheckedOutGitCommitHash as MethodClosure
getCheckedOutBranch = this.&getCheckedOutBranch getCheckedOutBranch = this.&getCheckedOutBranch as MethodClosure
} }