Fix maketext tool to work correctly on darwin-x86
Bug: 6661783 Bug: 6662536 Change-Id: I5e657975098a0630ceb1821053cda68bf481d2e4main
parent
9ada9f1bdd
commit
9c9802e647
|
@ -27,14 +27,13 @@ import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
public class JarUtils {
|
public class JarUtils {
|
||||||
private static final String MANIFEST = "META-INF/MANIFEST.MF";
|
|
||||||
|
|
||||||
private JarUtils() {
|
private JarUtils() {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JarFile getJarFile(final ClassLoader loader) {
|
public static JarFile getJarFile(final Class<?> mainClass) {
|
||||||
final URL resUrl = loader.getResource(MANIFEST);
|
final String mainClassPath = "/" + mainClass.getName().replace('.', '/') + ".class";
|
||||||
|
final URL resUrl = mainClass.getResource(mainClassPath);
|
||||||
if (!resUrl.getProtocol().equals("jar")) {
|
if (!resUrl.getProtocol().equals("jar")) {
|
||||||
throw new RuntimeException("Should run as jar");
|
throw new RuntimeException("Should run as jar");
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class LabelText {
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
final Options options = new Options(args);
|
final Options options = new Options(args);
|
||||||
final JarFile jar = JarUtils.getJarFile(LabelText.class.getClassLoader());
|
final JarFile jar = JarUtils.getJarFile(LabelText.class);
|
||||||
final MoreKeysResources resources = new MoreKeysResources(jar);
|
final MoreKeysResources resources = new MoreKeysResources(jar);
|
||||||
resources.writeToJava(options.mJava);
|
resources.writeToJava(options.mJava);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class MoreKeysResources {
|
||||||
final File outputFile = new File(outPackage,
|
final File outputFile = new File(outPackage,
|
||||||
JAVA_TEMPLATE.replace(".tmpl", ".java"));
|
JAVA_TEMPLATE.replace(".tmpl", ".java"));
|
||||||
outPackage.mkdirs();
|
outPackage.mkdirs();
|
||||||
ps = new PrintStream(outputFile);
|
ps = new PrintStream(outputFile, "UTF-8");
|
||||||
}
|
}
|
||||||
lnr = new LineNumberReader(new InputStreamReader(JarUtils.openResource(template)));
|
lnr = new LineNumberReader(new InputStreamReader(JarUtils.openResource(template)));
|
||||||
inflateTemplate(lnr, ps);
|
inflateTemplate(lnr, ps);
|
||||||
|
|
Loading…
Reference in New Issue