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
* limitations under the License.
*/
import proguard.gradle.ProGuardTask
apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
@ -43,7 +45,7 @@ task cleanOutputDirectory(type: Delete) {
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()
// 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)) {
def hash = getCheckedOutGitCommitHash();
def hash = getCheckedOutGitCommitHash()
if (hash == null) {
project.ext.set("hash", "dirty")
project.ext.set("apktool_version", apktoolversion_major + "-dirty")
println "Building SNAPSHOT (no .git folder found)";
println "Building SNAPSHOT (no .git folder found)"
} else {
project.ext.set("hash", hash);
project.ext.set("apktool_version", apktoolversion_major + "-" + hash + "-SNAPSHOT");
println "Building SNAPSHOT (" + getCheckedOutBranch() + "): " + hash;
project.ext.set("hash", hash)
project.ext.set("apktool_version", apktoolversion_major + "-" + hash + "-SNAPSHOT")
println "Building SNAPSHOT (" + getCheckedOutBranch() + "): " + hash
}
} else {
project.ext.set("hash", "")
if (apktoolversion_minor.length() > 0) {
project.ext.set("apktool_version", apktoolversion_major + "-" + apktoolversion_minor);
project.ext.set("apktool_version", apktoolversion_major + "-" + apktoolversion_minor)
} 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 {
@ -99,7 +99,7 @@ build.doFirst {
"We found a " + javaVersion + " JDK\n" +
"Please update JAVA_HOME to use at least a 1.8 JDK\n" +
"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>
*
@ -21,8 +23,8 @@ def getCheckedOutGitCommitHash() {
def head
try {
head = new File(gitFolder + "HEAD").text.split(":")
} catch(Exception e) {
return null;
} catch(Exception ignored) {
return null
}
def isCommit = head.length == 1
@ -38,13 +40,13 @@ def getCheckedOutBranch() {
def head
try {
head = new File(gitFolder + "HEAD").text.split("/")
return head[2].trim();
} catch(Exception e) {
return "SNAPSHOT";
return head[2].trim()
} catch(Exception ignored) {
return "SNAPSHOT"
}
}
ext {
getCheckedOutGitCommitHash = this.&getCheckedOutGitCommitHash
getCheckedOutBranch = this.&getCheckedOutBranch
getCheckedOutGitCommitHash = this.&getCheckedOutGitCommitHash as MethodClosure
getCheckedOutBranch = this.&getCheckedOutBranch as MethodClosure
}