# HG changeset patch # User Jaroslav Tulach # Date 1459139678 -7200 # Node ID a9d37af23a0093f17c4e1ecdc9c853913811b30a # Parent c433787ebe2d0ca44876d631a412b80c45e904e8 Record name of an OSGi bundle to be used when Maven coordinates are missing diff -r c433787ebe2d -r a9d37af23a00 benchmarks/jbox2d-osgi/pom.xml --- a/benchmarks/jbox2d-osgi/pom.xml Mon Mar 28 05:56:31 2016 +0200 +++ b/benchmarks/jbox2d-osgi/pom.xml Mon Mar 28 06:34:38 2016 +0200 @@ -6,6 +6,7 @@ benchmarks 0.18 + JBox2d OSGI Wrapper bundle jbox2d-osgi @@ -41,6 +42,15 @@ true + maven-jar-plugin + 2.6 + + + false + + + + org.apidesign.bck2brwsr bck2brwsr-maven-plugin ${project.version} diff -r c433787ebe2d -r a9d37af23a00 launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Mon Mar 28 05:56:31 2016 +0200 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Mon Mar 28 06:34:38 2016 +0200 @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; @@ -649,6 +650,7 @@ Object compileJar(URL jarURL) throws IOException { List libraries = new ArrayList(); + Map osgiJars = new HashMap(); for (ClassLoader loader : loaders) { Enumeration en = loader.getResources("META-INF/MANIFEST.MF"); while (en.hasMoreElements()) { @@ -662,13 +664,26 @@ final String g = attr.getValue("Bck2BrwsrGroupId"); final String v = attr.getValue("Bck2BrwsrVersion"); final String d = attr.getValue("Bck2BrwsrDebug"); + final String n = attr.getValue("Bck2BrwsrName"); if (g != null && a != null && v != null && "true".equals(d)) { libraries.add(new String[] { - a, g, v, key + a, g, v, key, n }); } } + final Attributes main = mf.getMainAttributes(); + String symbol = main.getValue("Bundle-SymbolicName"); + String version; + if (symbol == null) { + symbol = main.getValue("OpenIDE-Module-Name"); + version = main.getValue("OpenIDE-Module-SpecificationVersion"); + } else { + version = main.getValue("Bundle-Version"); + } + if (symbol != null) { + osgiJars.put(symbol, new Object[] { e, version }); + } } } URL precompiled = null; @@ -693,6 +708,16 @@ } } } + if (precompiled == null) { + for (ClassLoader loader : loaders) { + for (String[] lib : libraries) { + Object[] urlVersion = osgiJars.get(lib[4]); + if (urlVersion != null && urlVersion[1].toString().startsWith(lib[2])) { + precompiled = loader.getResource(lib[3]); + } + } + } + } Object ret = BaseHTTPLauncher.this.compileJar(jarURL, precompiled); ignore.add(jarURL); return ret; diff -r c433787ebe2d -r a9d37af23a00 rt/mojo/pom.xml --- a/rt/mojo/pom.xml Mon Mar 28 05:56:31 2016 +0200 +++ b/rt/mojo/pom.xml Mon Mar 28 06:34:38 2016 +0200 @@ -39,8 +39,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff -r c433787ebe2d -r a9d37af23a00 rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java Mon Mar 28 05:56:31 2016 +0200 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/AOTLibrary.java Mon Mar 28 06:34:38 2016 +0200 @@ -31,6 +31,7 @@ import java.util.List; import java.util.jar.Attributes; import java.util.jar.JarEntry; +import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import org.apache.maven.artifact.Artifact; @@ -106,6 +107,7 @@ attr.putValue("Bck2BrwsrGroupId", prj.getGroupId()); attr.putValue("Bck2BrwsrVersion", prj.getVersion()); attr.putValue("Bck2BrwsrMinified", "true"); + bundleName(attr, mainJar); m.getEntries().put(minified, attr); } if (!"false".equals(debug)) { @@ -114,6 +116,7 @@ attr.putValue("Bck2BrwsrGroupId", prj.getGroupId()); attr.putValue("Bck2BrwsrVersion", prj.getVersion()); attr.putValue("Bck2BrwsrDebug", "true"); + bundleName(attr, mainJar); m.getEntries().put(debug, attr); } @@ -129,6 +132,8 @@ attr.putValue("Bck2BrwsrGroupId", a.getGroupId()); attr.putValue("Bck2BrwsrVersion", a.getVersion()); attr.putValue("Bck2BrwsrDebug", "true"); + bundleName(attr, a.getFile()); + m.getEntries().put(artifactName(a, true), attr); } { @@ -137,6 +142,7 @@ attr.putValue("Bck2BrwsrGroupId", a.getGroupId()); attr.putValue("Bck2BrwsrVersion", a.getVersion()); attr.putValue("Bck2BrwsrMinified", "true"); + bundleName(attr, a.getFile()); m.getEntries().put(artifactName(a, false), attr); } } @@ -237,6 +243,19 @@ return a.getGroupId() + "-" + a.getArtifactId() + (debug ? "-debug.js" : "-min.js"); } + private static void bundleName(Attributes attr, File file) throws IOException { + try (JarFile jf = new JarFile(file)) { + Attributes main = jf.getManifest().getMainAttributes(); + String version = main.getValue("Bundle-SymbolicName"); + if (version == null) { + version = main.getValue("OpenIDE-Module-Name"); + } + if (version != null) { + attr.putValue("Bck2BrwsrName", version); + } + } + } + private static URLClassLoader buildClassLoader(File root, Collection deps) throws MalformedURLException { List arr = new ArrayList(); if (root != null) {