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;
}
use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class MavenBndRepository method startPoll.
private void startPoll(final IndexFile index) {
Workspace ws = registry.getPlugin(Workspace.class);
if ((ws != null) && (ws.getGestalt().containsKey(Constants.GESTALT_BATCH) || ws.getGestalt().containsKey(Constants.GESTALT_CI) || ws.getGestalt().containsKey(Constants.GESTALT_OFFLINE))) {
return;
}
final AtomicBoolean busy = new AtomicBoolean();
indexPoller = Processor.getScheduledExecutor().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
if (busy.getAndSet(true))
return;
try {
poll();
} catch (Exception e) {
reporter.error("Error when polling index for %s for change", this);
} finally {
busy.set(false);
}
}
}, 5000, 5000, TimeUnit.MILLISECONDS);
}
use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class TestingMojo method testing.
private void testing(File runFile, FileSetRepository fileSetRepository) throws Exception {
if (!runFile.exists()) {
logger.error("Could not find bnd run file {}", runFile);
errors++;
return;
}
String bndrun = getNamePart(runFile);
File workingDir = new File(cwd, bndrun);
File cnf = new File(workingDir, Workspace.CNFDIR);
IO.mkdirs(cnf);
try (Bndrun run = Bndrun.createBndrun(null, runFile)) {
run.setBase(workingDir);
Workspace workspace = run.getWorkspace();
workspace.setBuildDir(cnf);
workspace.setOffline(session.getSettings().isOffline());
workspace.addBasicPlugin(fileSetRepository);
for (RepositoryPlugin repo : workspace.getRepositories()) {
repo.list(null);
}
run.getInfo(workspace);
report(run);
if (!run.isOk()) {
return;
}
if (resolve) {
try {
String runBundles = run.resolve(failOnChanges, false);
if (!run.isOk()) {
return;
}
run.setProperty(Constants.RUNBUNDLES, runBundles);
} catch (ResolutionException re) {
logger.error("Unresolved requirements: {}", ResolveProcess.format(re.getUnresolvedRequirements()));
throw re;
} finally {
report(run);
}
}
try {
run.test(new File(reportsDir, bndrun), null);
} finally {
report(run);
}
}
}
use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class ResolveCommand method _repos.
public void _repos(RepoOptions options) throws Exception {
Workspace ws = bnd.getWorkspace(options.workspace());
if (ws == null) {
error("No workspace");
return;
}
List<Repository> plugins = ws.getPlugins(Repository.class);
bnd.out.println(Strings.join("\n", plugins));
}
use of aQute.bnd.build.Workspace in project bnd by bndtools.
the class bnd method _sync.
/**
* Force a cache update of the workspace
*
* @throws Exception
*/
public void _sync(projectOptions options) throws Exception {
Workspace ws = getWorkspace((File) null);
if (ws == null) {
error("Cannot find workspace, either reside in a project directory, point to a project with --project, or reside in the workspace directory");
return;
}
ws.syncCache();
}
Aggregations