use of aQute.bnd.repository.fileset.FileSetRepository in project bnd by bndtools.
the class ResolverMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
DependencyResolver dependencyResolver = new DependencyResolver(project, repositorySession, resolver, system);
FileSetRepository fileSetRepository = dependencyResolver.getFileSetRepository(project.getName(), bundles, useMavenDependencies);
for (File runFile : bndruns) {
resolve(runFile, fileSetRepository);
}
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
if (errors > 0)
throw new MojoExecutionException(errors + " errors found");
}
use of aQute.bnd.repository.fileset.FileSetRepository in project bnd by bndtools.
the class DependencyResolver method getFileSetRepository.
public FileSetRepository getFileSetRepository(String name, Collection<File> bundlesInputParameter, boolean useMavenDependencies) throws Exception {
Collection<File> bundles = new ArrayList<>();
if (useMavenDependencies) {
Map<File, ArtifactResult> dependencies = resolve();
bundles.addAll(dependencies.keySet());
// TODO Find a better way to get all the artifacts produced by this project!!!
File current = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".jar");
if (current.exists() && !bundles.contains(current)) {
bundles.add(current);
}
}
if (bundlesInputParameter != null) {
bundles.addAll(bundlesInputParameter);
}
return new FileSetRepository(name, bundles);
}
use of aQute.bnd.repository.fileset.FileSetRepository in project bnd by bndtools.
the class ExportMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
try {
DependencyResolver dependencyResolver = new DependencyResolver(project, repositorySession, resolver, system);
FileSetRepository fileSetRepository = dependencyResolver.getFileSetRepository(project.getName(), bundles, useMavenDependencies);
for (File runFile : bndruns) {
export(runFile, fileSetRepository);
}
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
if (errors > 0)
throw new MojoExecutionException(errors + " errors found");
}
use of aQute.bnd.repository.fileset.FileSetRepository in project bnd by bndtools.
the class TestingMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip || skipTests) {
return;
}
try {
DependencyResolver dependencyResolver = new DependencyResolver(project, repositorySession, resolver, system);
FileSetRepository fileSetRepository = dependencyResolver.getFileSetRepository(project.getName(), bundles, useMavenDependencies);
if (testingSelect != null) {
logger.info("Using selected testing file {}", testingSelect);
testing(testingSelect, fileSetRepository);
} else {
Glob g = new Glob(testing == null ? "*" : testing);
logger.info("Matching glob {}", g);
for (File runFile : bndruns) {
if (g.matcher(runFile.getName()).matches())
testing(runFile, fileSetRepository);
else
logger.info("Skipping {}", g);
}
}
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
if (errors > 0)
throw new MojoExecutionException(errors + " errors found");
}
use of aQute.bnd.repository.fileset.FileSetRepository in project bndtools by bndtools.
the class MavenImplicitProjectRepository method createRepo.
private void createRepo(IMavenProjectFacade mavenProjectFacade, IProgressMonitor monitor) {
try {
List<File> toIndex = new ArrayList<>();
File file = guessBundleFile(mavenProjectFacade);
if (file != null) {
toIndex.add(file);
}
IClasspathEntry[] classpath = buildpathManager.getClasspath(mavenProjectFacade.getProject(), IClasspathManager.CLASSPATH_RUNTIME, true, monitor);
for (IClasspathEntry cpe : classpath) {
IClasspathAttribute[] extraAttributes = cpe.getExtraAttributes();
for (IClasspathAttribute ea : extraAttributes) {
if (ea.getName().equals("maven.scope") && (ea.getValue().equals("compile") || ea.getValue().equals("runtime"))) {
if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
file = getOutputFile(extraAttributes);
if (file != null) {
toIndex.add(file);
}
} else if ((cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY) && (cpe.getContentKind() == IPackageFragmentRoot.K_BINARY)) {
file = cpe.getPath().toFile();
if (file != null) {
toIndex.add(file);
}
}
}
}
}
fileSetRepository = new FileSetRepository(getName(), toIndex);
Central.refreshPlugin(this);
} catch (Exception e) {
if (logger.isErrorEnabled()) {
logger.error("Failed to create implicit repository for m2e project {}", getName(), e);
}
}
}
Aggregations