mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-10 12:06:05 +01:00
refactor gradle version system for release, snapshots and non-git snapshots
This commit is contained in:
parent
c80e906f53
commit
e3ed1a448a
@ -13,8 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
version = apktoolversion
|
||||
apply plugin: 'fatjar'
|
||||
|
||||
configurations {
|
||||
@ -35,7 +33,7 @@ gradle.taskGraph.whenReady {
|
||||
}
|
||||
|
||||
task proguard(type: JavaExec, dependsOn: fatJar) {
|
||||
def outFile = jar.destinationDir.getPath() + '/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension
|
||||
def outFile = jar.destinationDir.getPath() + '/' + "apktool" + '-' + project.apktool_version + '-small' + '.' + jar.extension
|
||||
inputs.file jar.archivePath
|
||||
outputs.file outFile
|
||||
|
||||
|
@ -16,26 +16,11 @@
|
||||
|
||||
import org.apache.tools.ant.filters.*
|
||||
|
||||
// release
|
||||
if (!('release' in gradle.startParameter.taskNames)) {
|
||||
ant.loadfile(srcFile: "../../.git/refs/heads/master", property: fullrev, failonerror: false);
|
||||
if (ant.properties[fullrev] == null) {
|
||||
gitrev_version = "SNAPSHOT_DEV";
|
||||
println "Building SNAPSHOT (no .git folder found)";
|
||||
} else {
|
||||
gitrev_version = ant.properties[fullrev].substring(0,10);
|
||||
println "Building SNAPSHOT: " + gitrev_version;
|
||||
}
|
||||
} else {
|
||||
gitrev_version = '';
|
||||
println "Building RELEASE: " + apktoolversion;
|
||||
}
|
||||
|
||||
processResources {
|
||||
from('src/main/resources/properties') {
|
||||
include '**/*.properties'
|
||||
into 'properties'
|
||||
filter(ReplaceTokens, tokens: [version: apktoolversion, gitrev: gitrev_version] )
|
||||
filter(ReplaceTokens, tokens: [version: project.apktool_version, gitrev: project.hash] )
|
||||
}
|
||||
from('src/main/resources/') {
|
||||
include '**/*.jar'
|
||||
@ -43,10 +28,12 @@ processResources {
|
||||
|
||||
includeEmptyDirs = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile ("junit:junit:4.10") {
|
||||
exclude(module: 'hamcrest-core')
|
||||
}
|
||||
|
||||
compile project(':brut.j.dir'),
|
||||
project(':brut.j.util'),
|
||||
project(':brut.j.common'),
|
||||
|
70
build.gradle
70
build.gradle
@ -13,14 +13,60 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'license'
|
||||
|
||||
ext.apktoolversion = '2.0.0-Beta8'
|
||||
ext.fullrev = '';
|
||||
ext.gitrev_version = '';
|
||||
def apktoolversion_major = '2.0.0'
|
||||
def apktoolversion_minor = 'Beta8';
|
||||
|
||||
if (!('release' in gradle.startParameter.taskNames)) {
|
||||
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)";
|
||||
} else {
|
||||
project.ext.set("hash", hash);
|
||||
project.ext.set("apktool_version", apktoolversion_major + "-" + hash + "-SNAPSHOT");
|
||||
println "Building SNAPSHOT (" + getCheckedOutBranch() + "): " + hash;
|
||||
}
|
||||
} else {
|
||||
project.ext.set("hash", "")
|
||||
project.ext.set("apktool_version", apktoolversion_major + "-" + apktoolversion_minor);
|
||||
println "Building RELEASE (" + getCheckedOutBranch() + "): " + apktoolversion_major + "-" + apktoolversion_minor;
|
||||
}
|
||||
|
||||
// https://gist.github.com/JonasGroeger/7620911
|
||||
def getCheckedOutGitCommitHash() {
|
||||
def gitFolder = "$projectDir/.git/"
|
||||
def takeFromHash = 6
|
||||
|
||||
def head
|
||||
try {
|
||||
head = new File(gitFolder + "HEAD").text.split(":")
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
def isCommit = head.length == 1
|
||||
if(isCommit) return head[0].trim().take(takeFromHash)
|
||||
|
||||
def refHead = new File(gitFolder + head[1].trim())
|
||||
refHead.text.trim().take takeFromHash
|
||||
}
|
||||
|
||||
def getCheckedOutBranch() {
|
||||
def gitFolder = "$projectDir/.git/"
|
||||
|
||||
def head
|
||||
try {
|
||||
head = new File(gitFolder + "HEAD").text.split("/")
|
||||
} catch(Exception e) {
|
||||
return "";
|
||||
}
|
||||
return head[2].trim();
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -37,22 +83,11 @@ build.doFirst {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Compatibility {
|
||||
String version
|
||||
Compatibility(String versionValue) {
|
||||
def matcher = (versionValue =~ /Java (\d)/)
|
||||
version = matcher[0][1]
|
||||
}
|
||||
String toString() { version }
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '1.8'
|
||||
}
|
||||
|
||||
// If anyone uses this outside of GoogleCode (Apktool) developers. I will hunt you down and hurt you.
|
||||
// This is for official releases only.
|
||||
// used for official releases only. Please don't use
|
||||
task release {
|
||||
}
|
||||
|
||||
@ -61,7 +96,6 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.5.0'
|
||||
classpath 'eu.appsatori:gradle-fatjar-plugin:0.2-rc1'
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user