Commit c59b65e7 authored by Skylot's avatar Skylot

build: add 'dist' task

parent bd4c61d3
...@@ -3,7 +3,7 @@ jdk: ...@@ -3,7 +3,7 @@ jdk:
- oraclejdk7 - oraclejdk7
- openjdk7 - openjdk7
- openjdk6 - openjdk6
script: gradle clean build samples script: gradle clean build
notifications: notifications:
email: email:
- skylot@gmail.com - skylot@gmail.com
...@@ -16,7 +16,7 @@ Latest version available at ...@@ -16,7 +16,7 @@ Latest version available at
git clone https://github.com/skylot/jadx.git git clone https://github.com/skylot/jadx.git
cd jadx cd jadx
./gradlew clean build ./gradlew dist
(on Windows, use `gradlew.bat` instead of `./gradlew`) (on Windows, use `gradlew.bat` instead of `./gradlew`)
...@@ -37,13 +37,13 @@ Run **jadx** on itself: ...@@ -37,13 +37,13 @@ Run **jadx** on itself:
``` ```
jadx[-gui] [options] <input file> (.dex, .apk or .jar) jadx[-gui] [options] <input file> (.dex, .apk or .jar)
options: options:
-d, --output-dir - output directory -d, --output-dir - output directory
-j, --threads-count - processing threads count -j, --threads-count - processing threads count
-f, --fallback - make simple dump (using goto instead of 'if', 'for', etc) -f, --fallback - make simple dump (using goto instead of 'if', 'for', etc)
--cfg - save methods control flow graph --cfg - save methods control flow graph to dot file
--raw-cfg - save methods control flow graph (use raw instructions) --raw-cfg - save methods control flow graph (use raw instructions)
-v, --verbose - verbose output -v, --verbose - verbose output
-h, --help - print this help -h, --help - print this help
Example: Example:
jadx -d out classes.dex jadx -d out classes.dex
``` ```
......
...@@ -12,16 +12,17 @@ subprojects { ...@@ -12,16 +12,17 @@ subprojects {
gradle.projectsEvaluated { gradle.projectsEvaluated {
tasks.withType(Compile) { tasks.withType(Compile) {
options.compilerArgs << "-Xlint" << "-Xlint:unchecked" << "-Xlint:deprecation" if (!"${it}".contains(":jadx-samples:")) {
options.compilerArgs << "-Xlint" << "-Xlint:unchecked" << "-Xlint:deprecation"
}
} }
} }
jar { jar {
version = jadxVersion version = jadxVersion
} manifest {
mainAttributes('jadx-version' : jadxVersion)
manifest { }
mainAttributes('jadx-version' : jadxVersion)
} }
dependencies { dependencies {
...@@ -48,10 +49,16 @@ task pack(type: Zip, dependsOn: copyArtifacts) { ...@@ -48,10 +49,16 @@ task pack(type: Zip, dependsOn: copyArtifacts) {
from copyArtifacts.destinationDir from copyArtifacts.destinationDir
} }
task build(dependsOn: pack) { task dist(dependsOn: pack) {
description = 'Build jadx distribution zip' description = 'Build jadx distribution zip'
} }
task samples(dependsOn: 'jadx-samples:samples') {
}
task build(dependsOn: [dist, samples]) {
}
task clean(type: Delete) { task clean(type: Delete) {
delete buildDir delete buildDir
} }
...@@ -59,4 +66,3 @@ task clean(type: Delete) { ...@@ -59,4 +66,3 @@ task clean(type: Delete) {
task wrapper(type: Wrapper) { task wrapper(type: Wrapper) {
gradleVersion = '1.8' gradleVersion = '1.8'
} }
package jadx.core; package jadx.core;
import jadx.core.utils.Utils;
public class Consts { public class Consts {
public static final String JADX_VERSION = Utils.getJadxVersion(); public static final String JADX_VERSION = Jadx.getVersion();
public static final boolean DEBUG = false; public static final boolean DEBUG = false;
......
...@@ -19,10 +19,15 @@ import jadx.core.dex.visitors.regions.ProcessVariables; ...@@ -19,10 +19,15 @@ import jadx.core.dex.visitors.regions.ProcessVariables;
import jadx.core.dex.visitors.regions.RegionMakerVisitor; import jadx.core.dex.visitors.regions.RegionMakerVisitor;
import jadx.core.dex.visitors.typeresolver.FinishTypeResolver; import jadx.core.dex.visitors.typeresolver.FinishTypeResolver;
import jadx.core.dex.visitors.typeresolver.TypeResolver; import jadx.core.dex.visitors.typeresolver.TypeResolver;
import jadx.core.utils.Utils;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.jar.Manifest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -73,4 +78,19 @@ public class Jadx { ...@@ -73,4 +78,19 @@ public class Jadx {
passes.add(new CodeGen(args)); passes.add(new CodeGen(args));
return passes; return passes;
} }
public static String getVersion() {
try {
Enumeration<URL> resources = Utils.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream());
String ver = manifest.getMainAttributes().getValue("jadx-version");
if (ver != null)
return ver;
}
} catch (IOException e) {
LOG.error("Can't get manifest file", e);
}
return "dev";
}
} }
...@@ -3,14 +3,10 @@ package jadx.core.utils; ...@@ -3,14 +3,10 @@ package jadx.core.utils;
import jadx.core.utils.exceptions.JadxRuntimeException; import jadx.core.utils.exceptions.JadxRuntimeException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.URL;
import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.jar.Manifest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -126,22 +122,6 @@ public class Utils { ...@@ -126,22 +122,6 @@ public class Utils {
return end; return end;
} }
public static String getJadxVersion() {
try {
Enumeration<URL> resources =
Utils.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream());
String ver = manifest.getMainAttributes().getValue("jadx-version");
if (ver != null)
return ver;
}
} catch (IOException e) {
LOG.error("Can't get manifest file", e);
}
return "dev";
}
public static void makeDirsForFile(File file) { public static void makeDirsForFile(File file) {
File dir = file.getParentFile(); File dir = file.getParentFile();
if (!dir.exists()) { if (!dir.exists()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment