Search in sources :

Example 86 with Workspace

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

the class BndPreferences method setWorkspaceOffline.

public void setWorkspaceOffline(boolean b) {
    Workspace workspace = Central.getWorkspaceIfPresent();
    if (workspace != null) {
        workspace.setOffline(b);
    }
    store.setValue(PREF_WORKSPACE_OFFLINE, b);
}
Also used : Workspace(aQute.bnd.build.Workspace)

Example 87 with Workspace

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

the class RepositoryTreeContentProvider method getElements.

@Override
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
    Collection<Object> result;
    if (inputElement instanceof Workspace) {
        result = new ArrayList<Object>();
        Workspace workspace = (Workspace) inputElement;
        addRepositoryPlugins(result, workspace);
    } else if (inputElement instanceof Collection) {
        result = new ArrayList<Object>();
        addCollection(result, (Collection<Object>) inputElement);
    } else if (inputElement instanceof Object[]) {
        result = new ArrayList<Object>();
        addCollection(result, Arrays.asList(inputElement));
    } else {
        result = Collections.emptyList();
    }
    return result.toArray();
}
Also used : ArrayList(java.util.ArrayList) Collection(java.util.Collection) Workspace(aQute.bnd.build.Workspace)

Example 88 with Workspace

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

the class ProjectTest method testWildcardBuildPathWithRepoFilter.

public void testWildcardBuildPathWithRepoFilter() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project project = ws.getProject("repofilter");
    assertNotNull(project);
    project.setProperty("-buildpath", "*; repo=Relea*");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(2, buildpath.size());
    assertEquals(Container.TYPE.REPO, buildpath.get(0).getType());
    assertEquals("org.apache.felix.configadmin", buildpath.get(0).getBundleSymbolicName());
    assertEquals(Container.TYPE.REPO, buildpath.get(1).getType());
    assertEquals("p3", buildpath.get(1).getBundleSymbolicName());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 89 with Workspace

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

the class ProjectTest method testGetOutputFile.

/**
	 * Check that the output property can be used to name the output binary.
	 */
public void testGetOutputFile() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project top = ws.getProject("p1");
    //
    // We expect p1 to be a single project (no sub builders)
    //
    assertEquals("p1 must be singleton", 1, top.getSubBuilders().size());
    Builder builder = top.getSubBuilders().iterator().next();
    assertEquals("p1 must be singleton", "p1", builder.getBsn());
    // Check the default bsn.jar form
    assertEquals(new File(top.getTarget(), "p1.jar"), top.getOutputFile("p1"));
    assertEquals(new File(top.getTarget(), "p1.jar"), top.getOutputFile("p1", "0"));
    // Add the version to the filename
    top.setProperty("-outputmask", "${@bsn}-${version;===s;${@version}}.jar");
    assertEquals(new File(top.getTarget(), "p1-1.260.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
    top.setProperty("Bundle-Version", "1.260.0.SNAPSHOT");
    assertEquals(new File(top.getTarget(), "p1-1.260.0-SNAPSHOT.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
    top.setProperty("-outputmask", "${@bsn}-${version;===S;${@version}}.jar");
    assertEquals(new File(top.getTarget(), "p1-1.260.0-SNAPSHOT.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
    top.setProperty("Bundle-Version", "1.260.0.NOTSNAPSHOT");
    top.setProperty("-outputmask", "${@bsn}-${version;===S;${@version}}.jar");
    assertEquals(new File(top.getTarget(), "p1-1.260.0.NOTSNAPSHOT.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
    top.setProperty("-outputmask", "${@bsn}-${version;===s;${@version}}.jar");
    assertEquals(new File(top.getTarget(), "p1-1.260.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
    top.setProperty("Bundle-Version", "42");
    top.setProperty("-outputmask", "${@bsn}-${version;===S;${@version}}.jar");
    assertEquals(new File(top.getTarget(), "p1-42.0.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
    top.setProperty("-outputmask", "${@bsn}-${version;===s;${@version}}.jar");
    assertEquals(new File(top.getTarget(), "p1-42.0.0.jar"), top.getOutputFile(builder.getBsn(), builder.getVersion()));
}
Also used : Project(aQute.bnd.build.Project) Builder(aQute.bnd.osgi.Builder) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Example 90 with Workspace

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

the class OSGiRepository method getIndex.

synchronized OSGiIndex getIndex(boolean refresh) throws Exception {
    HttpClient client = registry.getPlugin(HttpClient.class);
    Workspace ws = registry.getPlugin(Workspace.class);
    if (ws == null) {
        ws = Workspace.createDefaultWorkspace();
    }
    String cachePath = config.cache();
    File cache = (cachePath == null) ? ws.getCache(config.name()) : ws.getFile(cachePath);
    if (refresh)
        IO.delete(cache);
    List<String> strings = Strings.split(config.locations());
    List<URI> urls = new ArrayList<>(strings.size());
    for (String s : strings) {
        urls.add(new URI(s));
    }
    if (poller == null) {
        if (!(ws.getGestalt().containsKey(Constants.GESTALT_BATCH) || ws.getGestalt().containsKey(Constants.GESTALT_CI) || ws.getGestalt().containsKey(Constants.GESTALT_OFFLINE))) {
            int polltime = config.poll_time(DEFAULT_POLL_TIME);
            if (polltime > 0) {
                poller = Processor.getScheduledExecutor().scheduleAtFixedRate(new Runnable() {

                    @Override
                    public void run() {
                        if (inPoll.getAndSet(true))
                            return;
                        try {
                            poll();
                        } catch (Exception e) {
                            logger.debug("During polling", e);
                        } finally {
                            inPoll.set(false);
                        }
                    }
                }, polltime, polltime, TimeUnit.SECONDS);
            }
        }
    }
    index = new OSGiIndex(config.name(), client, cache, urls, config.max_stale(YEAR), refresh);
    stale = false;
    return index;
}
Also used : HttpClient(aQute.bnd.http.HttpClient) ArrayList(java.util.ArrayList) File(java.io.File) URI(java.net.URI) IOException(java.io.IOException) 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