aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-06-13 21:44:21 -0700
committerTadashi G. Takaoka <takaoka@google.com>2012-06-13 22:32:28 -0700
commit9c9802e6473e5e2e2b792d5f14502139feb49637 (patch)
tree29009420583a8e5c0d1dc5a9647441516a6330a9
parent9ada9f1bddc953453ca609610298ead9fe864e52 (diff)
downloadlatinime-9c9802e6473e5e2e2b792d5f14502139feb49637.tar.gz
latinime-9c9802e6473e5e2e2b792d5f14502139feb49637.tar.xz
latinime-9c9802e6473e5e2e2b792d5f14502139feb49637.zip
Fix maketext tool to work correctly on darwin-x86
Bug: 6661783 Bug: 6662536 Change-Id: I5e657975098a0630ceb1821053cda68bf481d2e4
-rw-r--r--tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java7
-rw-r--r--tools/maketext/src/com/android/inputmethod/latin/maketext/LabelText.java2
-rw-r--r--tools/maketext/src/com/android/inputmethod/latin/maketext/MoreKeysResources.java2
3 files changed, 5 insertions, 6 deletions
diff --git a/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java b/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java
index 366d73e20..07a6c300e 100644
--- a/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java
+++ b/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java
@@ -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");
}
diff --git a/tools/maketext/src/com/android/inputmethod/latin/maketext/LabelText.java b/tools/maketext/src/com/android/inputmethod/latin/maketext/LabelText.java
index a5abcf1c1..4a9236962 100644
--- a/tools/maketext/src/com/android/inputmethod/latin/maketext/LabelText.java
+++ b/tools/maketext/src/com/android/inputmethod/latin/maketext/LabelText.java
@@ -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);
}
diff --git a/tools/maketext/src/com/android/inputmethod/latin/maketext/MoreKeysResources.java b/tools/maketext/src/com/android/inputmethod/latin/maketext/MoreKeysResources.java
index a4835932b..37ac0d006 100644
--- a/tools/maketext/src/com/android/inputmethod/latin/maketext/MoreKeysResources.java
+++ b/tools/maketext/src/com/android/inputmethod/latin/maketext/MoreKeysResources.java
@@ -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);