public static Workspace createDefaultWorkspace() throws Exception { Workspace ws = new Workspace(BND_DEFAULT_WS, CNFDIR); return ws; }
public Project getProjectFromFile(File projectDir) { projectDir = projectDir.getAbsoluteFile(); assert projectDir.isDirectory(); if (getBase().equals(projectDir.getParentFile())) { return getProject(projectDir.getName()); } return null; }
/** * This static method finds the workspace and creates a project (or returns * an existing project) * * @param projectDir */ public static Project getProject(File projectDir) throws Exception { projectDir = projectDir.getAbsoluteFile(); assert projectDir.isDirectory(); Workspace ws = getWorkspace(projectDir.getParentFile()); return ws.getProject(projectDir.getName()); }
/** * Report details of this workspace */ @Override public void report(Map<String, Object> table) throws Exception { super.report(table); table.put("Workspace", toString()); table.put("Plugins", getPlugins(Object.class)); table.put("Repos", getRepositories()); table.put("Projects in build order", getBuildOrder()); }
WeakReference<Workspace> wsr = cache.get(getBase()); if ((wsr != null) && (wsr.get() == this)) { cache.remove(getBase()); cache.put(workspaceDir, wsr); buildDir = new File(workspaceDir, CNFDIR).getAbsoluteFile(); setBuildDir(buildDir); warning("No Build File in %s", workspaceDir); setProperties(buildFile, workspaceDir); propertiesChanged(); Attrs sysProps = OSGiHeader.parseProperties(mergeProperties(SYSTEMPROPERTIES)); for (Entry<String, String> e : sysProps.entrySet()) { System.setProperty(e.getKey(), e.getValue());
File parent = file.getParentFile(); boolean parentIsWorkspace = parent .equals(getWorkspace().getBase()); if (workspace.refresh()) { changed.addAll(workspace .getCurrentProjects()); if (workspace.isPresent(file.getName())) { Project project = workspace.getProject(file .getName()); changed.add(project);
public Workspace(File dir, String bndDir) throws Exception { super(getDefaults()); dir = dir.getAbsoluteFile(); if (!dir.exists() && !dir.mkdirs()) { throw new IOException("Could not create directory " + dir); } assert dir.isDirectory(); File buildDir = new File(dir, bndDir).getAbsoluteFile(); if (!buildDir.isDirectory()) buildDir = new File(dir, CNFDIR).getAbsoluteFile(); this.buildDir = buildDir; File buildFile = new File(buildDir, BUILDFILE).getAbsoluteFile(); if (!buildFile.isFile()) warning("No Build File in " + dir); setProperties(buildFile, dir); propertiesChanged(); // // There is a nasty bug/feature in Java that gives errors on our // SSL use of github. The flag jsse.enableSNIExtension should be set // to false. So here we provide a way to set system properties // as early as possible // Attrs sysProps = OSGiHeader.parseProperties(getProperty(SYSTEMPROPERTIES)); for (Entry<String,String> e : sysProps.entrySet()) { System.setProperty(e.getKey(), e.getValue()); } }
@Override public void init(Workspace ws) throws Exception { try (Project p = new Project(ws, ws.getFile("cnf"))) { created(p); } for (Project pp : ws.getAllProjects()) { created(pp); } }
public Workspace(File dir) throws Exception { dir = dir.getAbsoluteFile(); if (!dir.exists() && !dir.mkdirs()) { throw new IOException("Could not create directory " + dir); } assert dir.isDirectory(); File buildDir = new File(dir, BNDDIR).getAbsoluteFile(); if (!buildDir.isDirectory()) buildDir = new File(dir, CNFDIR).getAbsoluteFile(); this.buildDir = buildDir; File buildFile = new File(buildDir, BUILDFILE).getAbsoluteFile(); if (!buildFile.isFile()) warning("No Build File in " + dir); setProperties(buildFile, dir); propertiesChanged(); }
public static Workspace getWorkspace(File parent) throws Exception { File workspaceDir = parent.getAbsoluteFile(); // the cnf directory can actually be a // file that redirects while (workspaceDir.isDirectory()) { File test = new File(workspaceDir, CNFDIR); if (!test.exists()) test = new File(workspaceDir, BNDDIR); if (test.isDirectory()) break; if (test.isFile()) { String redirect = IO.collect(test).trim(); test = getFile(test.getParentFile(), redirect).getAbsoluteFile(); workspaceDir = test; } if (!test.exists()) throw new IllegalArgumentException("No Workspace found from: " + parent); } synchronized (cache) { WeakReference<Workspace> wsr = cache.get(workspaceDir); Workspace ws; if (wsr == null || (ws = wsr.get()) == null) { ws = new Workspace(workspaceDir); cache.put(workspaceDir, new WeakReference<Workspace>(ws)); } return ws; } }
public List<RepositoryPlugin> getRepositories() throws Exception { if (data.repositories == null) { data.repositories = getPlugins(RepositoryPlugin.class); for (RepositoryPlugin repo : data.repositories) { if (repo instanceof Prepare) { ((Prepare) repo).prepare(); } } } return data.repositories; }
public Workspace(File dir) throws Exception { dir = dir.getAbsoluteFile(); dir.mkdirs(); assert dir.isDirectory(); File buildDir = new File(dir, CNFDIR).getAbsoluteFile(); File buildFile = new File(buildDir, BUILDFILE).getAbsoluteFile(); if (!buildFile.isFile()) warning("No Build File in " + dir); setProperties(buildFile, dir); }
@Override public void delete(Project p) throws IOException { File root = p.getWorkspace() .getFile("pom.xml"); String rootPom = IO.collect(root); if (rootPom.contains(getTag(p))) { rootPom = rootPom.replaceAll("\n\\s*" + getTag(p) + "\\s*", "\n"); IO.store(rootPom, root); } }
Project project = Workspace.getProject(basedir); ws.setProperty(prop.getName(), prop.getValue()); for (Project p : ws.getCurrentProjects()) ws.getInfo(p, p + ":");
public Collection<Project> getBuildOrder() throws Exception { List<Project> result = new ArrayList<Project>(); for (Project project : getAllProjects()) { Collection<Project> dependsOn = project.getDependson(); getBuildOrder(dependsOn, result); if (!result.contains(project)) { result.add(project); } } return result; }
@Override public String getName() { return "Workspace " + workspace.getBase() .getName(); }
@Override public boolean refresh() { if (super.refresh()) { for (Project project : getCurrentProjects()) { project.propertiesChanged(); } return true; } return false; }
public Map<String,Action> getActions() { Map<String,Action> all = newMap(); Map<String,Action> actions = newMap(); fillActions(all); getWorkspace().fillActions(all); for (Map.Entry<String,Action> action : all.entrySet()) { String key = getReplacer().process(action.getKey()); if (key != null && key.trim().length() != 0) actions.put(key, action.getValue()); } return actions; }
@Override public SortedSet<Version> versions(String bsn) throws Exception { List<Version> versions = new ArrayList<>(); Collection<Project> projects = workspace.getAllProjects(); for (Project project : projects) { Map<String, Version> projectVersions = project.getVersions(); if (!projectVersions.containsKey(bsn)) { continue; } versions.add(projectVersions.get(bsn)); break; } if (versions.isEmpty()) return SortedList.empty(); return new SortedList<>(versions); }