Merge pull request #1496 from iBotPeaches/shadow-jar

Shadow Jar
This commit is contained in:
Connor Tumbleson 2017-05-08 09:02:47 -04:00 committed by GitHub
commit ea16f3ff1d
10 changed files with 88 additions and 25 deletions

View File

@ -20,7 +20,7 @@ before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libstdc++6:i386 lib32z1 expect
- git submodule update --init --recursive
script: ./gradlew build fatJar proguard
script: ./gradlew build shadowJar proguard
branches:
only:
- master

View File

@ -33,11 +33,11 @@ For example for the `2.2.1` release.
In order to maintain a clean slate. Run `gradlew clean` to start from a clean slate. Now lets build
the new version. We should not have any new commits since the tagged commit.
./gradlew build fatJar proguard release
./gradlew build shadowJar proguard release
The build should tell you what version you are building and it should match the commits you made previously.
➜ Apktool git:(master) ./gradlew build fatJar proguard release
➜ Apktool git:(master) ./gradlew build shadowJar proguard release
Building RELEASE (master): 2.2.2
### Testing the binary.

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'eu.appsatori.fatjar'
apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile depends.commons_cli
@ -30,22 +30,20 @@ buildscript {
}
}
gradle.taskGraph.whenReady {
fatJar {
jar {
manifest {
attributes("Main-Class": "brut.apktool.Main")
attributes 'Main-Class' : 'brut.apktool.Main'
}
}
}
task cleanOutputDirectory(type: Delete) {
delete fileTree(dir: jar.destinationDir.getPath(), exclude: "apktool-cli.jar")
delete fileTree(dir: jar.destinationDir.getPath(), exclude: "apktool-cli-all.jar")
}
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) {
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: shadowJar) {
def outFile = jar.destinationDir.getPath() + '/' + "apktool" + '-' + project.apktool_version + '-small' + '.' + jar.extension
injars fatJar.archivePath
injars shadowJar.archivePath
outjars outFile
libraryjars "${System.properties['java.home']}/lib/rt.jar"
@ -54,7 +52,6 @@ task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) {
dontoptimize
keep 'public class brut.apktool.Main { public static void main(java.lang.String[]); }'
keep 'class org.yaml.snakeyaml.** { public protected private *; }'
keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }'
dontwarn 'com.google.common.base.**'
dontwarn 'com.google.common.collect.**'

View File

@ -50,11 +50,9 @@ public class ResPluralsValue extends ResBagValue implements
continue;
}
ResScalarValue rawValue = item;
serializer.startTag(null, "item");
serializer.attribute(null, "quantity", QUANTITY_MAP[i]);
serializer.text(ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(item.encodeAsResXmlValue()));
serializer.text(ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(item.encodeAsResXmlNonEscapedItemValue()));
serializer.endTag(null, "item");
}
serializer.endTag(null, "plurals");

View File

@ -17,7 +17,7 @@
package brut.androlib.res.util;
import java.io.*;
import org.xmlpull.mxp1_serializer.MXSerializer;
import org.xmlpull.renamed.MXSerializer;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>

View File

@ -1,4 +1,4 @@
package org.xmlpull.mxp1_serializer;
package org.xmlpull.renamed;
import java.io.IOException;
import java.io.OutputStream;
@ -440,8 +440,8 @@ public class MXSerializer implements XmlSerializer {
// check that prefix is not duplicated ...
for (int i = elNamespaceCount[depth]; i < namespaceEnd; i++) {
if (prefix == namespacePrefix[i]) {
throw new IllegalStateException("duplicated prefix "
+ printable(prefix) + getLocation());
// Toss out extra namespaces at same depth to fix #1456
return;
}
}

View File

@ -0,0 +1,71 @@
/**
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright 2014 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib;
import brut.common.BrutException;
import brut.directory.ExtFile;
import brut.util.OS;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;
import static org.junit.Assert.assertTrue;
public class VectorDrawableTest {
@BeforeClass
public static void beforeClass() throws Exception {
TestUtils.cleanFrameworkFile();
sTmpDir = new ExtFile(OS.createTempDirectory());
TestUtils.copyResourceDir(VectorDrawableTest.class, "brut/apktool/issue1456/", sTmpDir);
}
@AfterClass
public static void afterClass() throws BrutException {
OS.rmdir(sTmpDir);
}
@Test
public void checkIfDrawableFileDecodesProperly() throws BrutException, IOException {
String apk = "issue1456.apk";
// decode issue1456.apk
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
apkDecoder.decode();
checkFileExists("res/drawable/ic_arrow_drop_down_black_24dp.xml");
checkFileExists("res/drawable/ic_android_black_24dp.xml");
}
private void checkFileExists(String path) throws BrutException {
File f = new File(sTestOrigDir, path);
assertTrue(f.isFile());
}
private static ExtFile sTmpDir;
private static ExtFile sTestOrigDir;
private final static Logger LOGGER = Logger.getLogger(VectorDrawableTest.class.getName());
}

View File

@ -21,17 +21,16 @@ buildscript {
options.encoding = "UTF-8"
}
dependencies {
classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}
}
apply plugin: 'maven'
apply from: 'gradle/functions.gradle'
def apktoolversion_major = '2.2.3'
def apktoolversion_minor = 'SNAPSHOT';
defaultTasks 'build', 'fatJar', 'proguard'
defaultTasks 'build', 'shadowJar', 'proguard'
allprojects {
apply plugin: 'java'
@ -80,8 +79,6 @@ task release {
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
ext {
depends = [

View File

@ -1,2 +1,2 @@
#!/usr/bin/env sh
./gradlew build fatJar
./gradlew build shadowJar