Author: tchemit Date: 2008-02-21 23:49:41 +0000 (Thu, 21 Feb 2008) New Revision: 220 Removed: trunk/jaxx/src/main/java/jaxx/compiler/JavaCCompiler.java Modified: trunk/jaxx/pom.xml trunk/jaxx/src/main/java/jaxx/compiler/CompilerOptions.java trunk/jaxx/src/main/java/jaxx/compiler/JAXXCompiler.java Log: suppression fonctionnalit?\195?\169 javac du generateur jaxx Modified: trunk/jaxx/pom.xml =================================================================== --- trunk/jaxx/pom.xml 2008-02-21 21:03:46 UTC (rev 219) +++ trunk/jaxx/pom.xml 2008-02-21 23:49:41 UTC (rev 220) @@ -29,13 +29,6 @@ <version>0.29-SNAPSHOT</version> <scope>compile</scope> </dependency> - <!-- pour la compilation --> - <dependency> - <groupId>com.sun</groupId> - <artifactId>tools</artifactId> - <version>1.6.0</version> - <scope>compile</scope> - </dependency> <!-- pour acceder aux BeansInfos swing via Introspector --> <dependency> <groupId>com.sun</groupId> Modified: trunk/jaxx/src/main/java/jaxx/compiler/CompilerOptions.java =================================================================== --- trunk/jaxx/src/main/java/jaxx/compiler/CompilerOptions.java 2008-02-21 21:03:46 UTC (rev 219) +++ trunk/jaxx/src/main/java/jaxx/compiler/CompilerOptions.java 2008-02-21 23:49:41 UTC (rev 220) @@ -11,7 +11,6 @@ private File javacTargetDirectory; private String classPath; private String javacOpts; - private boolean runJavac; private boolean keepJavaFiles; private boolean optimize; @@ -121,31 +120,6 @@ /** - * Returns whether or not <code>javac</code> should be run against the generated Java files. - * - * @return <code>true</code> if generated Java files should be compiled using <code>javac</code> - * @see #setRunJavac - */ - public boolean getRunJavac() { - return runJavac; - } - - - /** - * Sets whether or not <code>javac</code> is run against the generated Java files. Setting - * runJavac to <code>false</code> implies a <code>true</code> value for keepJavaFiles. - * - * @param runJavac <code>true</code> to compile generated Java files using <code>javac</code> - * @see #getRunJavac - */ - public void setRunJavac(boolean runJavac) { - this.runJavac = runJavac; - if (!runJavac) - setKeepJavaFiles(true); - } - - - /** * Returns whether or not optimization should be performed. * * @return whether or not optimizations should be performed Modified: trunk/jaxx/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- trunk/jaxx/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-02-21 21:03:46 UTC (rev 219) +++ trunk/jaxx/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-02-21 23:49:41 UTC (rev 220) @@ -1871,24 +1871,6 @@ } } - // javac - if (success && options.getRunJavac()) { - assert jaxxFiles.size() == jaxxFileClassNames.size(); - for (String className : jaxxFileClassNames) { - JAXXCompiler compiler = compilers.get(className); - if (compiler == null) { - throw new CompilerException("Internal error: could not find compiler for " + className + " during compilation"); - } - boolean keepJavaFiles = compiler.getOptions().getKeepJavaFiles(); - JavaCCompiler.runJavac(compiler); - if (compiler.failed) { - success = false; - } else if (!keepJavaFiles) { - compiler.getDest().delete(); - } - } - } - if (warningCount == 1) { System.err.println("1 warning"); } else if (warningCount > 0) { @@ -1926,7 +1908,6 @@ System.out.println(" -classpath <paths> paths to search for user classes"); System.out.println(" -cp <paths> same as -classpath"); System.out.println(" -d <directory> target directory for generated class files"); - System.out.println(" -javac_opts <opts> options to pass to javac"); System.out.println(" -java or -j produce .java files, but do not compile them"); System.out.println(" -keep or -k preserve generated .java files after compilation"); System.out.println(" -optimize or -o optimize during compilation"); @@ -1979,7 +1960,6 @@ options.setKeepJavaFiles(true); else if (arg[i].equals("-j") || arg[i].equals("-java")) { options.setKeepJavaFiles(true); - options.setRunJavac(false); } else if (arg[i].equals("-o") || arg[i].equals("-optimize")) options.setOptimize(true); else if (arg[i].equals("-version")) { Deleted: trunk/jaxx/src/main/java/jaxx/compiler/JavaCCompiler.java =================================================================== --- trunk/jaxx/src/main/java/jaxx/compiler/JavaCCompiler.java 2008-02-21 21:03:46 UTC (rev 219) +++ trunk/jaxx/src/main/java/jaxx/compiler/JavaCCompiler.java 2008-02-21 23:49:41 UTC (rev 220) @@ -1,130 +0,0 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ -package jaxx.compiler; - -import static jaxx.compiler.JAXXCompiler.URLtoFile; - -import java.io.File; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - - -/** - * Compiles java files into Java classes. - * - * @author chemit - */ -public class JavaCCompiler { - - static JAXXCompiler compiler; - static String classpath; - - public static void runJavac(final JAXXCompiler compiler) { - - CompilerOptions options = compiler.getOptions(); - JavaCCompiler.compiler = compiler; - runJavac( - options.getJavacTargetDirectory().getPath(), - options.getJavacOpts(), - compiler.getDest().getPath() - ); - } - - public static void runJavac(String destRoot, String options, String... destJavas) { - - PrintStream oldErr = System.err; - - String classpath = getClassPath(); - - try { - - initOutStream(oldErr); - - for (String destJava : destJavas) { - - String[] javacOpts = initOptions(classpath, destRoot, destJava, options==null?null:options.split("\\s+")); - //System.out.println("launch javac : "+ Arrays.toString(javacOpts)); - com.sun.tools.javac.Main.compile(javacOpts); - } - - } - catch (Exception e) { - System.err.println("An error occurred while invoking javac: "); - e.printStackTrace(); - if (compiler != null) { - compiler.setFailed(true); - } - } finally { - System.setErr(oldErr); - compiler = null; - } - } - - private static String getClassPath() { - if (classpath == null) { - // we do actually use a single jar for jaxx (core + runtime + swing +...) - String PATH = "/jaxx/compiler/JAXXCompiler.class"; - URL jaxxURL = JavaCCompiler.class.getResource(PATH); - if (jaxxURL == null) { - throw new InternalError("Can't-happen error: could not find /jaxx/compiler/JAXXCompiler.class on class path"); - } - String classpath = jaxxURL.toString(); - if (classpath.startsWith("jar:")) { - classpath = classpath.substring("jar:".length()); - classpath = classpath.substring(0, classpath.indexOf("!")); - classpath = URLtoFile(classpath).getPath(); - } else if (classpath.startsWith("file:")) { - // fix-bug : we must take the classpath and not the entire location to class - classpath = classpath.substring(0, classpath.length() - PATH.length()); - classpath = URLtoFile(classpath).getPath(); - } - JavaCCompiler.classpath = classpath; - } - return classpath; - } - - private static String[] initOptions(String classpath, String destRoot, String destJava, String... options) { - List<String> javacOpts = new ArrayList<String>(); - - if (options != null) { - javacOpts.addAll(Arrays.asList(options)); - } - if (destRoot != null) { - javacOpts.add("-d"); - javacOpts.add(destRoot); - classpath += File.pathSeparator + destRoot; - } - javacOpts.add("-classpath"); - javacOpts.add(classpath); - javacOpts.add(destJava); - return javacOpts.toArray(new String[javacOpts.size()]); - } - - private static void initOutStream(final PrintStream oldErr) { - System.setErr(new PrintStream(new FilterOutputStream(oldErr) { - @Override - public void write(byte[] b, int off, int len) throws IOException { - String stringValue = new String(b, off, len).trim(); - if (stringValue.startsWith("Error:") || stringValue.startsWith("Usage:") || stringValue.endsWith("error") || - stringValue.endsWith("errors")) { - if (compiler != null) { - compiler.setFailed(true); - } - } - if (stringValue.endsWith("uses unchecked or unsafe operations.") || - stringValue.endsWith("with -Xlint:unchecked for details.")) { - return; - } - super.write(b, off, len); - } - })); - } - -} \ No newline at end of file