public static Run getRun(File file) throws Exception { if (!file.isFile()) { return null; } File projectDir = file.getParentFile(); File workspaceDir = projectDir.getParentFile(); if (!workspaceDir.isDirectory()) { return null; } Workspace ws = getWorkspaceWithoutException(workspaceDir); if (ws == null) { return null; } return new Run(ws, projectDir, file); }
@Override public String getName() { return getPropertiesFile().getName(); }
public void addBundles(File bndrun) throws Exception { Run run = Run.createRun(getWorkspace(), bndrun); List<Bundle> bundles = new ArrayList<>(); for (Container c : run.getRunbundles()) { assert c.getError() == null; Bundle bundle = context.installBundle(c.getFile() .toURI() .toString()); bundles.add(bundle); } startAll(bundles); }
/** * Create a Run that will be stand alone if it contains -standalone. In that * case the given workspace is ignored. Otherwise, the workspace must be a * valid workspace. */ public static Run createRun(Workspace workspace, File file) throws Exception { Processor processor; if (workspace != null) { Run run = new Run(workspace, file); if (run.getProperties() .get(STANDALONE) == null) { return run; } // -standalone specified processor = run; } else { processor = new Processor(); processor.setProperties(file); } Workspace standaloneWorkspace = Workspace.createStandaloneWorkspace(processor, file.toURI()); Run run = new Run(standaloneWorkspace, file); return run; }
/** * Add some extra stuff to the builds() method like exporting. */ public Jar[] builds() throws Exception { project.exportedPackages.clear(); project.importedPackages.clear(); project.containedPackages.clear(); Jar[] jars = super.builds(); if (isOk()) { for (Run export : getExportedRuns()) { addClose(export); if ( export.getProperty(BUNDLE_SYMBOLICNAME) == null) { export.setProperty(BUNDLE_SYMBOLICNAME, getBsn() + ".run"); } Jar pack = export.pack(getProperty(PROFILE)); getInfo(export); if ( pack != null) { jars = concat(Jar.class,jars, pack); addClose(pack); } } } return jars; }
/** * Return the bndrun files that need to be exported * * @throws Exception */ public List<Run> getExportedRuns() throws Exception { Instructions runspec = new Instructions(getProperty(EXPORT)); List<Run> runs = new ArrayList<>(); Map<File, Attrs> files = runspec.select(getBase()); for (Entry<File, Attrs> e : files.entrySet()) { Run run = new Run(project.getWorkspace(), getBase(), e.getKey()); for (Entry<String, String> ee : e.getValue() .entrySet()) { run.setProperty(ee.getKey(), ee.getValue()); } runs.add(run); } return runs; }
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 _bootstrap(BootstrapOptions options) throws Exception { Workspace ws = getWorkspace(getBase()); File buildDir = ws.getBuildDir(); File bndFile = IO.getFile(buildDir, "bnd.bnd"); if (!bndFile.isFile()) { error("No bnd.bnd file found in cnf directory %s", bndFile); return; } Run run = new Run(ws, buildDir, bndFile); run.runLocal(); getInfo(run); }
String bndrunName = fileName.substring(0, fileName.lastIndexOf('.')); try (Run run = Run.createRun(bndWorkspace, bndrunFile)) { String repository = run.get(DOCKER_IMAGE); if (repository == null) { subProject.getLogger().log(LogLevel.INFO, "No docker information in bndrun {}", bndrunFile); return; Set<String> tags = new Parameters(run.get(DOCKER_TAGS)).keySet(); String from = run.get(DOCKER_FROM, DEFAULT_FROM_IMAGE); String maintainer = run.get(DOCKER_MAINTAINER); List<String> expose = new Parameters(run.get(DOCKER_EXPOSE)).keyList(); List<String> resources = new Parameters(run.get(DOCKER_RESOURCES)).keyList();
private Option bndToExam(Run bndRunInstruction) throws Exception { Collection<Option> urls = new ArrayList<>(); Collection<Container> bundles = bndRunInstruction.getRunbundles(); for (Container container : bundles) { urls.add(url(container.getFile().toURI().toASCIIString())); } return composite(urls.toArray(new Option[urls.size()])); } }
public boolean isStandalone() { return getWorkspace().getLayout() == WorkspaceLayout.STANDALONE; } }
/** * Add some extra stuff to the builds() method like exporting. */ @Override public Jar[] builds() throws Exception { project.exportedPackages.clear(); project.importedPackages.clear(); project.containedPackages.clear(); Jar[] jars = super.builds(); if (isOk()) { for (Run export : getExportedRuns()) { addClose(export); if (export.getProperty(BUNDLE_SYMBOLICNAME) == null) { export.setProperty(BUNDLE_SYMBOLICNAME, getBsn() + ".run"); } Jar pack = export.pack(getProperty(PROFILE)); getInfo(export); if (pack != null) { jars = concat(Jar.class, jars, pack); addClose(pack); } } } return jars; }
/** * Return the bndrun files that need to be exported * * @throws Exception */ public List<Run> getExportedRuns() throws Exception { Instructions runspec = new Instructions(getProperty(EXPORT)); List<Run> runs = new ArrayList<Run>(); Map<File,Attrs> files = runspec.select(getBase()); for (Entry<File,Attrs> e : files.entrySet()) { Run run = new Run(project.getWorkspace(), getBase(), e.getKey()); for (Entry<String,String> ee : e.getValue().entrySet()) { run.setProperty(ee.getKey(), ee.getValue()); } runs.add(run); } return runs; }
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); } } }
/** * Create a Run that will be stand alone if it contains -standalone. In that * case the given workspace is ignored. Otherwise, the workspace must be a * valid workspace. */ public static Run createRun(Workspace workspace, File file) throws Exception { Processor processor; if (workspace != null) { Run run = new Run(workspace, file); if (run.getProperties() .get(STANDALONE) == null) { return run; } // -standalone specified processor = run; } else { processor = new Processor(); processor.setProperties(file); } Workspace standaloneWorkspace = Workspace.createStandaloneWorkspace(processor, file.toURI()); Run run = new Run(standaloneWorkspace, file); return run; }
public boolean isStandalone() { return getWorkspace().getLayout() == WorkspaceLayout.STANDALONE; } }
/** * Add some extra stuff to the builds() method like exporting. */ public Jar[] builds() throws Exception { project.exportedPackages.clear(); project.importedPackages.clear(); project.containedPackages.clear(); Jar[] jars = super.builds(); if (isOk()) { for (Run export : getExportedRuns()) { addClose(export); if ( export.getProperty(BUNDLE_SYMBOLICNAME) == null) { export.setProperty(BUNDLE_SYMBOLICNAME, getBsn() + ".run"); } Jar pack = export.pack(getProperty(PROFILE)); getInfo(export); if ( pack != null) { jars = concat(Jar.class,jars, pack); addClose(pack); } } } return jars; }
/** * Return the bndrun files that need to be exported * * @throws Exception */ public List<Run> getExportedRuns() throws Exception { Instructions runspec = new Instructions(getProperty(EXPORT)); List<Run> runs = new ArrayList<Run>(); Map<File,Attrs> files = runspec.select(getBase()); for (Entry<File,Attrs> e : files.entrySet()) { Run run = new Run(project.getWorkspace(), getBase(), e.getKey()); for (Entry<String,String> ee : e.getValue().entrySet()) { run.setProperty(ee.getKey(), ee.getValue()); } runs.add(run); } return runs; }
/** * @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); } } }