# HG changeset patch # User Jaroslav Tulach # Date 1417846262 -3600 # Node ID e9b9d9ff062101e4a17ac027be5ea76dd86a1c40 # Parent 83151e1e0cace6f44c0bcd8006f2f34acd4ec47f javaquery demo now uses only extracted dependencies because javaquery.api generates additional bck2brwsr js files for core annotations library diff -r 83151e1e0cac -r e9b9d9ff0621 javaquery/api/pom.xml --- a/javaquery/api/pom.xml Sat Dec 06 06:49:24 2014 +0100 +++ b/javaquery/api/pom.xml Sat Dec 06 07:11:02 2014 +0100 @@ -41,6 +41,11 @@ + + + org.apidesign.bck2brwsr:core + + diff -r 83151e1e0cac -r e9b9d9ff0621 rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java Sat Dec 06 06:49:24 2014 +0100 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java Sat Dec 06 07:11:02 2014 +0100 @@ -76,6 +76,9 @@ @Parameter private String[] exports; + @Parameter + private String[] aotDeps; + @Override public void execute() throws MojoExecutionException, MojoFailureException { URLClassLoader loader; @@ -104,6 +107,31 @@ m.getEntries().put(debug, attr); } + if (aotDeps != null) { + for (Artifact a : prj.getArtifacts()) { + if (!matches(aotDeps, a)) { + continue; + } + + { + Attributes attr = new Attributes(); + attr.putValue("Bck2BrwsrArtifactId", a.getArtifactId()); + attr.putValue("Bck2BrwsrGroupId", a.getGroupId()); + attr.putValue("Bck2BrwsrVersion", a.getVersion()); + attr.putValue("Bck2BrwsrMinified", "true"); + m.getEntries().put(artifactName(a, true), attr); + } + { + Attributes attr = new Attributes(); + attr.putValue("Bck2BrwsrArtifactId", prj.getArtifactId()); + attr.putValue("Bck2BrwsrGroupId", prj.getGroupId()); + attr.putValue("Bck2BrwsrVersion", prj.getVersion()); + attr.putValue("Bck2BrwsrDebug", "true"); + m.getEntries().put(artifactName(a, false), attr); + } + } + } + FileOutputStream fos = new FileOutputStream(this.aotJar); JarOutputStream os = new JarOutputStream(fos, m); @@ -132,6 +160,33 @@ w.flush(); os.closeEntry(); } + + if (aotDeps != null) { + for (Artifact a : prj.getArtifacts()) { + if (!matches(aotDeps, a)) { + continue; + } + { + os.putNextEntry(new JarEntry(artifactName(a, true))); + Writer w = new OutputStreamWriter(os); + c. + obfuscation(ObfuscationLevel.NONE). + generate(w); + w.flush(); + os.closeEntry(); + } + { + os.putNextEntry(new JarEntry(artifactName(a, false))); + + Writer w = new OutputStreamWriter(os); + c. + obfuscation(ObfuscationLevel.FULL). + generate(w); + w.flush(); + os.closeEntry(); + } + } + } os.close(); projectHelper.attachArtifact(prj, "jar", "bck2brwsr", aotJar); @@ -140,6 +195,10 @@ } } + private static String artifactName(Artifact a, boolean debug) { + return a.getGroupId() + "-" + a.getArtifactId() + (debug ? "-debug.js" : "-min.js"); + } + private static URLClassLoader buildClassLoader(File root, Collection deps) throws MalformedURLException { List arr = new ArrayList(); if (root != null) { @@ -152,4 +211,27 @@ } return new URLClassLoader(arr.toArray(new URL[0]), Java2JavaScript.class.getClassLoader()); } + + private static boolean matches(String[] aotDeps, Artifact a) { + for (String d : aotDeps) { + String[] parts = d.split(":"); + for (int i = 0; i < parts.length; i++) { + if ("*".equals(parts[i])) { + parts[i] = null; + } + } + + if (parts[0] != null && !parts[0].equals(a.getGroupId())) { + continue; + } + if (parts[1] != null && !parts[1].equals(a.getArtifactId())) { + continue; + } + if (parts.length > 2 && parts[2] != null && !parts[2].equals(a.getClassifier())) { + continue; + } + return true; + } + return false; + } }