@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); }
@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 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); } } }
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); } } }
/** * @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); } } }
/** * @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); } } }