@Override public Entry<String, Resource> export(String type, Project project, Map<String, String> options) throws Exception { Configuration configuration = Converter.cnv(Configuration.class, options); project.prepare(); try (ProjectLauncher launcher = project.getProjectLauncher()) { launcher.setKeep(configuration.keep()); Jar jar = launcher.executable(); project.getInfo(launcher); String name = jar.getName(); String[] baseext = Strings.extension(name); if (baseext != null && ("bnd".equals(baseext[1]) || "bndrun".equals(baseext[1]))) { name = baseext[0]; } name = name + Constants.DEFAULT_JAR_EXTENSION; return new SimpleEntry<>(name, new JarResource(jar, true)); } } }
@SuppressWarnings("resource") public static Jar fromResource(String name, Resource resource) throws Exception { if (resource instanceof JarResource) { return ((JarResource) resource).getJar(); } else if (resource instanceof FileResource) { return new Jar(name, ((FileResource) resource).getFile()); } return new Jar(name).buildFromResource(resource); }
public Bundle install() throws Exception { try { Jar jar = new Jar("x"); for (Entry<String, Resource> e : additionalResources.entrySet()) { jar.putResource(e.getKey(), e.getValue()); } setJar(jar); jar = build(); try (JarResource j = new JarResource(jar);) { return context.installBundle("generated " + jar.getBsn(), j.openInputStream()); } } finally { close(); } }
@Override public Entry<String, Resource> export(String type, Project project, Map<String, String> options) throws Exception { project.prepare(); Collection<Container> runbundles = project.getRunbundles(); Jar jar = new Jar(project.getName()); jar.setDoNotTouchManifest(); for (Container container : runbundles) { File source = container.getFile(); String path = nonCollidingPath(jar, source.getName()); jar.putResource(path, new FileResource(source)); } return new SimpleEntry<>(jar.getName(), new JarResource(jar, true)); }
public Bundle install() throws Exception { try { Jar jar = new Jar("x"); for (Entry<String, Resource> e : additionalResources.entrySet()) { jar.putResource(e.getKey(), e.getValue()); } setJar(jar); jar = build(); try (JarResource j = new JarResource(jar);) { return context.installBundle("generated " + jar.getBsn(), j.openInputStream()); } } finally { close(); } }
@SuppressWarnings("resource") public static Jar fromResource(String name, Resource resource) throws Exception { if (resource instanceof JarResource) { return ((JarResource) resource).getJar(); } else if (resource instanceof FileResource) { return new Jar(name, ((FileResource) resource).getFile()); } return new Jar(name).buildFromResource(resource); }
@Override public Entry<String, Resource> export(String type, Project project, Map<String, String> options) throws Exception { project.prepare(); Collection<Container> runbundles = project.getRunbundles(); Jar jar = new Jar(project.getName()); jar.setDoNotTouchManifest(); for (Container container : runbundles) { File source = container.getFile(); String path = nonCollidingPath(jar, source.getName()); jar.putResource(path, new FileResource(source)); } return new SimpleEntry<>(jar.getName(), new JarResource(jar, true)); }
public void export(String runFilePath, boolean keep, File output) throws Exception { Map<String, String> options = Collections.singletonMap("keep", Boolean.toString(keep)); Entry<String, Resource> export; if (runFilePath == null || runFilePath.length() == 0 || ".".equals(runFilePath)) { clear(); export = export(ExecutableJarExporter.EXECUTABLE_JAR, options); } else { File runFile = IO.getFile(getBase(), runFilePath); if (!runFile.isFile()) throw new IOException( String.format("Run file %s does not exist (or is not a file).", IO.absolutePath(runFile))); try (Run run = new Run(getWorkspace(), getBase(), runFile)) { export = run.export(ExecutableJarExporter.EXECUTABLE_JAR, options); getInfo(run); } } if (export != null) { try (JarResource r = (JarResource) export.getValue()) { r.getJar() .write(output); } } }
@Override public Entry<String, Resource> export(String type, Project project, Map<String, String> options) throws Exception { Configuration configuration = Converter.cnv(Configuration.class, options); project.prepare(); try (ProjectLauncher launcher = project.getProjectLauncher()) { launcher.setKeep(configuration.keep()); Jar jar = launcher.executable(); project.getInfo(launcher); String name = jar.getName(); String[] baseext = Strings.extension(name); if (baseext != null && ("bnd".equals(baseext[1]) || "bndrun".equals(baseext[1]))) { name = baseext[0]; } name = name + Constants.DEFAULT_JAR_EXTENSION; return new SimpleEntry<>(name, new JarResource(jar, true)); } } }
public void export(String runFilePath, boolean keep, File output) throws Exception { Map<String, String> options = Collections.singletonMap("keep", Boolean.toString(keep)); Entry<String, Resource> export; if (runFilePath == null || runFilePath.length() == 0 || ".".equals(runFilePath)) { clear(); export = export(ExecutableJarExporter.EXECUTABLE_JAR, options); } else { File runFile = IO.getFile(getBase(), runFilePath); if (!runFile.isFile()) throw new IOException( String.format("Run file %s does not exist (or is not a file).", IO.absolutePath(runFile))); try (Run run = new Run(getWorkspace(), getBase(), runFile)) { export = run.export(ExecutableJarExporter.EXECUTABLE_JAR, options); getInfo(run); } } if (export != null) { try (JarResource r = (JarResource) export.getValue()) { r.getJar() .write(output); } } }
dot.putResource(path, new JarResource(jar)); setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
/** * @since 2.4 */ public void exportRunbundles(String runFilePath, File outputDir) throws Exception { Map<String, String> options = Collections.emptyMap(); Entry<String, Resource> export; if (runFilePath == null || runFilePath.length() == 0 || ".".equals(runFilePath)) { clear(); export = export(RunbundlesExporter.RUNBUNDLES, options); } else { File runFile = IO.getFile(getBase(), runFilePath); if (!runFile.isFile()) throw new IOException( String.format("Run file %s does not exist (or is not a file).", IO.absolutePath(runFile))); try (Run run = new Run(getWorkspace(), getBase(), runFile)) { export = run.export(RunbundlesExporter.RUNBUNDLES, options); getInfo(run); } } if (export != null) { try (JarResource r = (JarResource) export.getValue()) { r.getJar() .writeFolder(outputDir); } } }
addClose(jar); String path = "WEB-INF/lib/" + f.getName(); dot.putResource(path, new JarResource(jar)); setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
/** * @since 2.4 */ public void exportRunbundles(String runFilePath, File outputDir) throws Exception { Map<String, String> options = Collections.emptyMap(); Entry<String, Resource> export; if (runFilePath == null || runFilePath.length() == 0 || ".".equals(runFilePath)) { clear(); export = export(RunbundlesExporter.RUNBUNDLES, options); } else { File runFile = IO.getFile(getBase(), runFilePath); if (!runFile.isFile()) throw new IOException( String.format("Run file %s does not exist (or is not a file).", IO.absolutePath(runFile))); try (Run run = new Run(getWorkspace(), getBase(), runFile)) { export = run.export(RunbundlesExporter.RUNBUNDLES, options); getInfo(run); } } if (export != null) { try (JarResource r = (JarResource) export.getValue()) { r.getJar() .writeFolder(outputDir); } } }
addClose(jar); String path = "WEB-INF/lib/" + f.getName(); dot.putResource(path, new JarResource(jar)); setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
addClose(jar); String path = "WEB-INF/lib/" + f.getName(); dot.putResource(path, new JarResource(jar)); setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
dot.putResource(path, new JarResource(jar)); setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
Jar javadoc = javadoc(jdoc, project, exports.keySet()); logger.info(LIFECYCLE, "Writing javadoc jar"); File javadocFile = write(tmp, new JarResource(javadoc), "javadoc.jar"); logger.info(LIFECYCLE, "Writing main file"); File mainFile = write(tmp, new JarResource(main), "main.jar"); logger.info(LIFECYCLE, "Writing sources file"); File srcFile = write(tmp, new JarResource(main), "src.jar");
Jar javadoc = javadoc(jdoc, project, exports.keySet()); logger.info(LIFECYCLE, "Writing javadoc jar"); File javadocFile = write(tmp, new JarResource(javadoc), "javadoc.jar"); logger.info(LIFECYCLE, "Writing main file"); File mainFile = write(tmp, new JarResource(main), "main.jar"); logger.info(LIFECYCLE, "Writing sources file"); File srcFile = write(tmp, new JarResource(main), "src.jar");
private void noSuchFile(Jar jar, String clause, Map<String, String> extra, String source, String destinationPath) throws Exception { List<Jar> src = getJarsFromName(source, Constants.INCLUDE_RESOURCE + " " + source); if (!src.isEmpty()) { for (Jar j : src) { String quoted = j.getSource() != null ? j.getSource() .getName() : j.getName(); // Do not touch the manifest so this also // works for signed files. j.setDoNotTouchManifest(); JarResource jarResource = new JarResource(j); String path = destinationPath.replace(source, quoted); logger.debug("copy d={} s={} path={}", jar, j, path); copy(jar, path, jarResource, extra); } } else { Resource lastChance = make.process(source); if (lastChance != null) { String x = extra.get("extra"); if (x != null) lastChance.setExtra(x); copy(jar, destinationPath, lastChance, extra); } else error("Input file does not exist: %s", source).header(source) .context(clause); } }