use of aQute.bnd.osgi.repository.ResourcesRepository in project bnd by bndtools.
the class ReleasePluginImpl method createIndex.
private ResourcesRepository createIndex(List<IPom> releasedArtifacts, IMavenRepo storage, String prefix) throws Exception {
ResourcesRepository repo = new ResourcesRepository();
for (IPom pom : releasedArtifacts) {
try {
System.out.println("Indexing " + pom);
Promise<File> promise = storage.get(pom.binaryArchive());
File file = promise.getValue();
ResourceBuilder rb = new ResourceBuilder();
String uri = prefix + pom.binaryArchive().remotePath;
rb.addFile(file, new URI(uri));
repo.add(rb.build());
} catch (Exception e) {
indexProject.exception(e, "Failed to index artifact %s", pom.binaryArchive());
}
}
return repo;
}
use of aQute.bnd.osgi.repository.ResourcesRepository in project bnd by bndtools.
the class LocalIndexerMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
logger.debug("skip project as configured");
return;
}
if (baseFile == null) {
baseFile = outputFile.getParentFile();
}
logger.debug("Indexing dependencies in folder: {}", inputDir.getAbsolutePath());
logger.debug("Outputting index to: {}", outputFile.getAbsolutePath());
logger.debug("Producing additional gzip index: {}", includeGzip);
logger.debug("URI paths will be relative to: {}", baseFile);
Set<File> toIndex = new HashSet<>();
toIndex.addAll(asList(inputDir.listFiles()));
BaseFileURLResolver baseFileURLResolver = new BaseFileURLResolver();
ResourcesRepository resourcesRepository = new ResourcesRepository();
XMLResourceGenerator xmlResourceGenerator = new XMLResourceGenerator();
for (File file : toIndex) {
ResourceBuilder resourceBuilder = new ResourceBuilder();
try {
resourceBuilder.addFile(file, baseFileURLResolver.resolver(file));
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
resourcesRepository.add(resourceBuilder.build());
}
try {
IO.mkdirs(outputFile.getParentFile());
xmlResourceGenerator.repository(resourcesRepository).save(outputFile);
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
if (fail) {
throw new MojoExecutionException("One or more URI lookups failed");
}
if (includeGzip) {
File gzipOutputFile = new File(outputFile.getPath() + ".gz");
try {
xmlResourceGenerator.save(gzipOutputFile);
} catch (Exception e) {
throw new MojoExecutionException("Unable to create the gzipped output file");
}
}
}
Aggregations