Commit 772c664d authored by Skylot's avatar Skylot

Store version number in manifest

parent 29840e03
...@@ -7,9 +7,10 @@ apply plugin: 'idea' ...@@ -7,9 +7,10 @@ apply plugin: 'idea'
sourceCompatibility = 1.6 sourceCompatibility = 1.6
targetCompatibility = 1.6 targetCompatibility = 1.6
version = 'dev' version = file('version').readLines().get(0)
mainClassName = "jadx.Main" mainClassName = "jadx.Main"
manifest.mainAttributes("jadx-version" : version)
project.ext { project.ext {
mainSamplesClass = "jadx.samples.RunTests" mainSamplesClass = "jadx.samples.RunTests"
......
package jadx; package jadx;
import jadx.utils.Utils;
public class Consts { public class Consts {
public static final String JADX_VERSION = "dev"; public static final String JADX_VERSION = Utils.getJadxVersion();
public static final boolean DEBUG = false; public static final boolean DEBUG = false;
......
...@@ -110,7 +110,7 @@ public class JadxArgs { ...@@ -110,7 +110,7 @@ public class JadxArgs {
JCommander jc = new JCommander(this); JCommander jc = new JCommander(this);
// print usage in not sorted fields order (by default its sorted by description) // print usage in not sorted fields order (by default its sorted by description)
PrintStream out = System.out; PrintStream out = System.out;
out.println("jadx - dex to java decompiler, version: '" + Consts.JADX_VERSION + "'"); out.println("jadx - dex to java decompiler, version: " + Consts.JADX_VERSION);
out.println(); out.println();
out.println("usage: jadx [options] " + jc.getMainParameterDescription()); out.println("usage: jadx [options] " + jc.getMainParameterDescription());
out.println("options:"); out.println("options:");
......
package jadx.utils; package jadx.utils;
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.LoggerFactory;
public class Utils { public class Utils {
private static final Logger LOG = LoggerFactory.getLogger(Utils.class);
public static String cleanObjectName(String obj) { public static String cleanObjectName(String obj) {
int last = obj.length() - 1; int last = obj.length() - 1;
...@@ -52,4 +60,20 @@ public class Utils { ...@@ -52,4 +60,20 @@ public class Utils {
} }
return sb.toString(); return sb.toString();
} }
public static String getJadxVersion() {
try {
Enumeration<URL> resources =
new Utils().getClass().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";
}
} }
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