Store version number in manifest
This commit is contained in:
+2
-1
@@ -7,9 +7,10 @@ apply plugin: 'idea'
|
||||
sourceCompatibility = 1.6
|
||||
targetCompatibility = 1.6
|
||||
|
||||
version = 'dev'
|
||||
version = file('version').readLines().get(0)
|
||||
|
||||
mainClassName = "jadx.Main"
|
||||
manifest.mainAttributes("jadx-version" : version)
|
||||
|
||||
project.ext {
|
||||
mainSamplesClass = "jadx.samples.RunTests"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package jadx;
|
||||
|
||||
import jadx.utils.Utils;
|
||||
|
||||
public class Consts {
|
||||
public static final String JADX_VERSION = "dev";
|
||||
public static final String JADX_VERSION = Utils.getJadxVersion();
|
||||
|
||||
public static final boolean DEBUG = false;
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ public class JadxArgs {
|
||||
JCommander jc = new JCommander(this);
|
||||
// print usage in not sorted fields order (by default its sorted by description)
|
||||
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("usage: jadx [options] " + jc.getMainParameterDescription());
|
||||
out.println("options:");
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package jadx.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Utils {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Utils.class);
|
||||
|
||||
public static String cleanObjectName(String obj) {
|
||||
int last = obj.length() - 1;
|
||||
@@ -52,4 +60,20 @@ public class Utils {
|
||||
}
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user