# HG changeset patch # User Jaroslav Tulach # Date 1420966477 -3600 # Node ID f6057dc5922c7343b5caecb9e329a6ce2d94a305 # Parent 75671373fa87fb9d61ab71e02f3ace7b8bb509e8 Honor ignoreBootClassPath attribute in all mojos diff -r 75671373fa87 -r f6057dc5922c rt/aot/src/main/java/org/apidesign/bck2brwsr/aot/Bck2BrwsrJars.java --- a/rt/aot/src/main/java/org/apidesign/bck2brwsr/aot/Bck2BrwsrJars.java Sat Jan 10 19:38:00 2015 +0100 +++ b/rt/aot/src/main/java/org/apidesign/bck2brwsr/aot/Bck2BrwsrJars.java Sun Jan 11 09:54:37 2015 +0100 @@ -96,8 +96,35 @@ public static Bck2Brwsr configureFrom( Bck2Brwsr c, File jar, final ClassLoader classpath ) throws IOException { + return configureFrom(c, jar, classpath, true); + } + + /** Creates new compiler pre-configured from the content of + * provided JAR file. The compiler will compile all classes. + * The system understands OSGi manifest entries and NetBeans + * module system manifest entries and will export + * all packages that are exported in the JAR file. The system + * also recognizes META-INF/services and makes sure the class names + * are not mangled. + * + * @param c the compiler to {@link Bck2Brwsr#addClasses(java.lang.String...) add classes}, + * {@link Bck2Brwsr#addResources(java.lang.String...) add resources} and + * {@link Bck2Brwsr#addExported(java.lang.String...) exported objects} to. + * Can be null - in such case an + * {@link Bck2Brwsr#newCompiler() empty compiler} is constructed. + * @param jar the file to process + * @param classpath additional resources to make available during + * compilation, but not include them in the generated JavaScript + * @param ignoreBootClassPath should we ignore classes on bootclasspath? + * @return newly configured compiler + * @throws IOException if something goes wrong + * @since 0.14 + */ + public static Bck2Brwsr configureFrom( + Bck2Brwsr c, File jar, final ClassLoader classpath, final boolean ignoreBootClassPath + ) throws IOException { if (jar.isDirectory()) { - return configureDir(c, jar, classpath); + return configureDir(ignoreBootClassPath, c, jar, classpath); } final JarFile jf = new JarFile(jar); final List classes = new ArrayList<>(); @@ -105,7 +132,7 @@ Set exported = new HashSet<>(); class JarRes extends EmulationResources implements Bck2Brwsr.Resources { JarRes() { - super(classpath, classes); + super(ignoreBootClassPath, classpath, classes); } @Override public InputStream get(String resource) throws IOException { @@ -236,8 +263,10 @@ private final Map converted = new HashMap<>(); private final BytecodeProcessor proc; private final ClassLoader cp; + private final boolean ignoreBootClassPath; - protected EmulationResources(ClassLoader cp, List classes) { + protected EmulationResources(boolean ignoreBootClassPath, ClassLoader cp, List classes) { + this.ignoreBootClassPath = ignoreBootClassPath; this.classes = classes; this.cp = cp != null ? cp : Bck2BrwsrJars.class.getClassLoader(); BytecodeProcessor p; @@ -273,7 +302,7 @@ LOG.log(Level.FINE, "Cannot find {0}", name); return null; } - if (u.toExternalForm().contains("/rt.jar!")) { + if (ignoreBootClassPath && u.toExternalForm().contains("/rt.jar!")) { LOG.log(Level.WARNING, "No bootdelegation for {0}", name); return null; } @@ -307,12 +336,12 @@ } } - private static Bck2Brwsr configureDir(Bck2Brwsr c, final File dir, ClassLoader cp) throws IOException { + private static Bck2Brwsr configureDir(final boolean ignoreBootClassPath, Bck2Brwsr c, final File dir, ClassLoader cp) throws IOException { List arr = new ArrayList<>(); List classes = new ArrayList<>(); class DirRes extends EmulationResources { public DirRes(ClassLoader cp, List classes) { - super(cp, classes); + super(ignoreBootClassPath, cp, classes); } @Override diff -r 75671373fa87 -r f6057dc5922c rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java Sat Jan 10 19:38:00 2015 +0100 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java Sun Jan 11 09:54:37 2015 +0100 @@ -78,7 +78,10 @@ @Parameter private String[] aotDeps; - + + @Parameter(defaultValue = "true") + private boolean ignoreBootClassPath; + @Override public void execute() throws MojoExecutionException, MojoFailureException { URLClassLoader loader; @@ -161,7 +164,7 @@ continue; } getLog().info("Generating bck2brwsr for " + a.getFile()); - Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, a.getFile(), loader); + Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, a.getFile(), loader, ignoreBootClassPath); if (exports != null) { for (String e : exports) { c = c.addExported(e.replace('.', '/')); @@ -197,7 +200,7 @@ } private Bck2Brwsr configureMain(URLClassLoader loader) throws IOException { - Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, mainJar, loader); + Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, mainJar, loader, ignoreBootClassPath); if (exports != null) { for (String e : exports) { c = c.addExported(e.replace('.', '/')); diff -r 75671373fa87 -r f6057dc5922c rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java Sat Jan 10 19:38:00 2015 +0100 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AheadOfTime.java Sun Jan 11 09:54:37 2015 +0100 @@ -85,6 +85,9 @@ @Parameter(defaultValue = "true") private boolean generateAotLibraries; + @Parameter(defaultValue = "true") + private boolean ignoreBootClassPath; + /** * The obfuscation level for the generated JavaScript file. * @@ -131,7 +134,7 @@ getLog().info("Skipping " + mainJavaScript + " as it already exists."); } else { getLog().info("Generating " + mainJavaScript); - Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, mainJar, loader); + Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, mainJar, loader, ignoreBootClassPath); if (exports != null) { for (String e : exports) { c = c.addExported(e.replace('.', '/')); @@ -201,7 +204,7 @@ } getLog().info("Generating " + js); Writer w = new OutputStreamWriter(new FileOutputStream(js), "UTF-8"); - Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, a.getFile(), loader); + Bck2Brwsr c = Bck2BrwsrJars.configureFrom(null, a.getFile(), loader, ignoreBootClassPath); c. obfuscation(obfuscation). generate(w);