1.1 --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/Java2JavaScript.java Tue Apr 29 14:27:36 2014 +0200
1.2 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/Java2JavaScript.java Wed Apr 30 15:04:10 2014 +0200
1.3 @@ -33,12 +33,16 @@
1.4 import org.apache.maven.plugins.annotations.LifecyclePhase;
1.5 import org.apache.maven.plugins.annotations.Mojo;
1.6 import org.apache.maven.plugins.annotations.Parameter;
1.7 +import org.apache.maven.plugins.annotations.ResolutionScope;
1.8 import org.apache.maven.project.MavenProject;
1.9 import org.apidesign.vm4brwsr.Bck2Brwsr;
1.10 import org.apidesign.vm4brwsr.ObfuscationLevel;
1.11
1.12 /** Compiles classes into JavaScript. */
1.13 -@Mojo(name="j2js", defaultPhase=LifecyclePhase.PROCESS_CLASSES)
1.14 +@Mojo(name="j2js",
1.15 + requiresDependencyResolution = ResolutionScope.COMPILE,
1.16 + defaultPhase=LifecyclePhase.PROCESS_CLASSES
1.17 +)
1.18 public class Java2JavaScript extends AbstractMojo {
1.19 public Java2JavaScript() {
1.20 }
1.21 @@ -46,7 +50,7 @@
1.22 @Parameter(defaultValue="${project.build.directory}/classes")
1.23 private File classes;
1.24 /** JavaScript file to generate */
1.25 - @Parameter
1.26 + @Parameter(defaultValue="${project.build.directory}/bck2brwsr.js")
1.27 private File javascript;
1.28
1.29 /** Additional classes that should be pre-compiled into the javascript
1.30 @@ -66,6 +70,10 @@
1.31 */
1.32 @Parameter(defaultValue="NONE")
1.33 private ObfuscationLevel obfuscation;
1.34 +
1.35 + /** Should classes from rt.jar be included? */
1.36 + @Parameter(defaultValue = "false")
1.37 + private boolean ignoreBootClassPath;
1.38
1.39 /**
1.40 * Indicates whether to create an extension library
1.41 @@ -81,6 +89,9 @@
1.42 if (!classes.isDirectory()) {
1.43 throw new MojoExecutionException("Can't find " + classes);
1.44 }
1.45 + if (javascript == null) {
1.46 + throw new MojoExecutionException("Need to define 'javascript' attribute with a path to file to generate");
1.47 + }
1.48
1.49 List<String> arr = new ArrayList<String>();
1.50 long newest = collectAllClasses("", classes, arr);
1.51 @@ -95,12 +106,12 @@
1.52 }
1.53
1.54 try {
1.55 - URLClassLoader url = buildClassLoader(classes, prj.getDependencyArtifacts());
1.56 + URLClassLoader url = buildClassLoader(classes, prj.getArtifacts());
1.57 FileWriter w = new FileWriter(javascript);
1.58 Bck2Brwsr.newCompiler().
1.59 obfuscation(obfuscation).
1.60 library(library).
1.61 - resources(url).
1.62 + resources(url, ignoreBootClassPath).
1.63 addRootClasses(arr.toArray(new String[0])).
1.64 generate(w);
1.65 w.close();