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;
|
||||
|
||||
public class JarUtils {
|
||||
private static final String MANIFEST = "META-INF/MANIFEST.MF";
|
||||
|
||||
private JarUtils() {
|
||||
// This utility class is not publicly instantiable.
|
||||
}
|
||||
|
||||
public static JarFile getJarFile(final ClassLoader loader) {
|
||||
final URL resUrl = loader.getResource(MANIFEST);
|
||||
public static JarFile getJarFile(final Class<?> mainClass) {
|
||||
final String mainClassPath = "/" + mainClass.getName().replace('.', '/') + ".class";
|
||||
final URL resUrl = mainClass.getResource(mainClassPath);
|
||||
if (!resUrl.getProtocol().equals("jar")) {
|
||||
throw new RuntimeException("Should run as jar");
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class LabelText {
|
|||
|
||||
public static void main(final String[] 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);
|
||||
resources.writeToJava(options.mJava);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class MoreKeysResources {
|
|||
final File outputFile = new File(outPackage,
|
||||
JAVA_TEMPLATE.replace(".tmpl", ".java"));
|
||||
outPackage.mkdirs();
|
||||
ps = new PrintStream(outputFile);
|
||||
ps = new PrintStream(outputFile, "UTF-8");
|
||||
}
|
||||
lnr = new LineNumberReader(new InputStreamReader(JarUtils.openResource(template)));
|
||||
inflateTemplate(lnr, ps);
|
||||
|
|
Loading…
Reference in New Issue