Search in sources :

Example 51 with Workspace

use of aQute.bnd.build.Workspace in project bndtools by bndtools.

the class AvailableBundlesPart method getRepositories.

@Override
public List<RepositoryPlugin> getRepositories() {
    List<String> tmp = model.getRunRepos();
    includedRepos = (tmp == null) ? null : new HashSet<String>(tmp);
    Workspace workspace = model.getWorkspace();
    List<RepositoryPlugin> repos;
    try {
        repos = RepositoryUtils.listRepositories(workspace, true);
    } catch (Exception e) {
        repos = Collections.emptyList();
    }
    return repos;
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) HashSet(java.util.HashSet) Workspace(aQute.bnd.build.Workspace)

Example 52 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class bnd method _release.

/**
	 * Release the project
	 * 
	 * @throws Exception
	 */
@Description("Release this project")
public void _release(releaseOptions options) throws Exception {
    Set<Project> projects = new LinkedHashSet<Project>();
    Workspace ws = Workspace.findWorkspace(getBase());
    if (ws == null) {
        error("Workspace option was specified but cannot find a workspace from %s", getBase());
        return;
    }
    if (options.workspace()) {
        projects.addAll(ws.getAllProjects());
    }
    Project project = getProject(options.project());
    if (project != null) {
        projects.add(project);
    }
    if (projects.isEmpty()) {
        error("Cannot find any projects");
        return;
    }
    String repo = options.repo();
    if (repo != null) {
        RepositoryPlugin repository = ws.getRepository(repo);
        if (repository == null) {
            error("No such release repo %s%nFound:%n%s", repository, Strings.join("\n", ws.getRepositories()));
        }
    }
    for (Project p : projects) {
        if (repo != null) {
            p.setProperty(Constants.RELEASEREPO, repo);
        }
        p.release(options.test());
    }
    getInfo(project);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Project(aQute.bnd.build.Project) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) Workspace(aQute.bnd.build.Workspace) Description(aQute.lib.getopt.Description)

Example 53 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class bnd method _plugins.

/**
	 * Show the loaded workspace plugins
	 * 
	 * @throws Exception
	 */
public void _plugins(projectOptions opts) throws Exception {
    Workspace ws = getWorkspace(opts.project());
    if (ws == null) {
        error("Can't find a workspace");
        return;
    }
    int n = 0;
    for (Object o : ws.getPlugins()) {
        String s = o.toString();
        if (s.trim().length() == 0)
            s = o.getClass().getName();
        out.printf("%03d %s%n", n++, s);
    }
}
Also used : Workspace(aQute.bnd.build.Workspace)

Example 54 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class bnd method __par.

/**
	 * Lets see if we can build in parallel
	 * 
	 * @throws Exception
	 */
public void __par(final ParallelBuildOptions options) throws Exception {
    ExecutorService pool = Executors.newCachedThreadPool();
    final AtomicBoolean quit = new AtomicBoolean();
    try {
        final Project p = getProject(options.project());
        final Workspace workspace = p == null || options.full() ? Workspace.getWorkspace(getBase()) : p.getWorkspace();
        if (!workspace.exists()) {
            error("cannot find workspace");
            return;
        }
        final Collection<Project> targets = p == null ? workspace.getAllProjects() : p.getDependson();
        final Forker<Project> forker = new Forker<Project>(pool);
        for (final Project dep : targets) {
            forker.doWhen(dep.getDependson(), dep, new Runnable() {

                public void run() {
                    if (!quit.get()) {
                        try {
                            dep.compile(false);
                            if (!quit.get())
                                dep.build();
                            if (!dep.isOk())
                                quit.set(true);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
        }
        System.err.flush();
        forker.start(20000);
        for (Project dep : targets) {
            getInfo(dep, dep + ": ");
        }
        if (p != null && p.isOk() && !options.full()) {
            p.compile(options.test());
            p.build();
            if (options.test() && p.isOk())
                p.test();
            getInfo(p);
        }
        workspace.close();
    } finally {
        pool.shutdownNow();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Project(aQute.bnd.build.Project) ExecutorService(java.util.concurrent.ExecutorService) Forker(aQute.libg.forker.Forker) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) ZipException(java.util.zip.ZipException) Workspace(aQute.bnd.build.Workspace)

Example 55 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class bnd method _bootstrap.

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);
}
Also used : Run(aQute.bnd.build.Run) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Aggregations

Workspace (aQute.bnd.build.Workspace)164 Project (aQute.bnd.build.Project)69 File (java.io.File)62 Processor (aQute.bnd.osgi.Processor)26 IOException (java.io.IOException)20 HashMap (java.util.HashMap)20 Container (aQute.bnd.build.Container)15 ArrayList (java.util.ArrayList)15 Version (aQute.bnd.version.Version)13 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)12 IProject (org.eclipse.core.resources.IProject)10 Run (aQute.bnd.build.Run)9 CoreException (org.eclipse.core.runtime.CoreException)9 Description (aQute.lib.getopt.Description)7 Collection (java.util.Collection)6 BndEditModel (aQute.bnd.build.model.BndEditModel)5 Jar (aQute.bnd.osgi.Jar)5 HttpTestServer (aQute.http.testservers.HttpTestServer)5 BuildException (org.apache.tools.ant.BuildException)5 IResource (org.eclipse.core.resources.IResource)5