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);
}
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();
}
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());
}
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()));
}
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;
}
Aggregations