Search in sources :

Example 1 with FileSetRepository

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");
}
Also used : FileSetRepository(aQute.bnd.repository.fileset.FileSetRepository) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ResolutionException(org.osgi.service.resolver.ResolutionException) DependencyResolver(aQute.bnd.maven.lib.resolve.DependencyResolver)

Example 2 with FileSetRepository

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);
}
Also used : FileSetRepository(aQute.bnd.repository.fileset.FileSetRepository) ArrayList(java.util.ArrayList) File(java.io.File) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 3 with FileSetRepository

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");
}
Also used : FileSetRepository(aQute.bnd.repository.fileset.FileSetRepository) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ResolutionException(org.osgi.service.resolver.ResolutionException) DependencyResolver(aQute.bnd.maven.lib.resolve.DependencyResolver)

Example 4 with FileSetRepository

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");
}
Also used : FileSetRepository(aQute.bnd.repository.fileset.FileSetRepository) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Glob(aQute.libg.glob.Glob) File(java.io.File) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ResolutionException(org.osgi.service.resolver.ResolutionException) DependencyResolver(aQute.bnd.maven.lib.resolve.DependencyResolver)

Example 5 with FileSetRepository

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);
        }
    }
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) FileSetRepository(aQute.bnd.repository.fileset.FileSetRepository) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

FileSetRepository (aQute.bnd.repository.fileset.FileSetRepository)5 File (java.io.File)5 DependencyResolver (aQute.bnd.maven.lib.resolve.DependencyResolver)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 ResolutionException (org.osgi.service.resolver.ResolutionException)3 ArrayList (java.util.ArrayList)2 Glob (aQute.libg.glob.Glob)1 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)1 IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1