org.jboss.shrinkwrap.resolver.api.maven.MavenResolvedArtifact Java Examples

The following examples show how to use org.jboss.shrinkwrap.resolver.api.maven.MavenResolvedArtifact. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShrinkwrapArtifactResolvingHelper.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public Set<ArtifactSpec> resolveAll(final Set<ArtifactSpec> specs) {
    if (specs.isEmpty()) {

        return specs;
    }

    resetListeners();
    final MavenResolvedArtifact[] artifacts =
            withResolver(r -> r.resolve(specs.stream().map(ArtifactSpec::mavenGav).collect(Collectors.toList()))
                    .withTransitivity()
                    .as(MavenResolvedArtifact.class));

    return Arrays.stream(artifacts).map(artifact -> {
        final MavenCoordinate coord = artifact.getCoordinate();
        return new ArtifactSpec("compile",
                coord.getGroupId(),
                coord.getArtifactId(),
                coord.getVersion(),
                coord.getPackaging().getId(),
                coord.getClassifier(),
                artifact.asFile());
    }).collect(Collectors.toSet());
}
 
Example #2
Source File: ShrinkwrapArtifactResolvingHelper.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public MavenResolvedArtifact[] withResolver(ResolverAction action) {
    resetListeners();
    try {
        return action.resolve(this.resolver);
    } finally {
        resolutionComplete();
    }
}
 
Example #3
Source File: ShrinkwrapArtifactResolvingHelper.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
public MavenResolvedArtifact[] withResolver(ResolverAction action) {
    resetListeners();
    try {
        return action.resolve(this.resolver);
    } finally {
        resolutionComplete();
    }
}
 
Example #4
Source File: ArquillianPackager.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
private static String getIdentifier(MavenResolvedArtifact a) {
    return a.getCoordinate().getGroupId() + ":" + a.getCoordinate().getArtifactId() + ":" + a.getCoordinate().getType() + ":" + a.getCoordinate().getClassifier();
}
 
Example #5
Source File: MavenDependencyDeclarationFactory.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public DeclaredDependencies create(FileSystemLayout ignored, ShrinkwrapArtifactResolvingHelper resolvingHelper) {
    final DeclaredDependencies declaredDependencies = new DeclaredDependencies();

    final PomEquippedResolveStage pom = MavenProfileLoader.loadPom(resolvingHelper.getResolver());

    // NonTransitiveStrategy
    final MavenResolvedArtifact[] explicitDeps =
            resolvingHelper.withResolver(r -> pom
                    .importRuntimeAndTestDependencies()
                    .resolve()
                    .withoutTransitivity()
                    .asResolvedArtifact()
            );

    // TransitiveStrategy
    for (MavenResolvedArtifact directDep : explicitDeps) {

        ArtifactSpec parent = new ArtifactSpec(
                directDep.getScope().toString(),
                directDep.getCoordinate().getGroupId(),
                directDep.getCoordinate().getArtifactId(),
                directDep.getCoordinate().getVersion(),
                directDep.getCoordinate().getPackaging().toString(),
                directDep.getCoordinate().getClassifier(),
                directDep.asFile()
        );
        MavenResolvedArtifact[] bucket =
                resolvingHelper.withResolver(r -> {
                                                 r.addDependency(resolvingHelper.createMavenDependency(parent));
                                                 return pom
                                                         .resolve()
                                                         .withTransitivity()
                                                         .asResolvedArtifact();
                                             }
                );

        for (MavenResolvedArtifact dep : bucket) {

            ArtifactSpec child = new ArtifactSpec(
                    dep.getScope().toString(),
                    dep.getCoordinate().getGroupId(),
                    dep.getCoordinate().getArtifactId(),
                    dep.getCoordinate().getVersion(),
                    dep.getCoordinate().getPackaging().toString(),
                    dep.getCoordinate().getClassifier(),
                    dep.asFile()
            );

            declaredDependencies.add(
                    parent,
                    child
            );
        }
    }

    return declaredDependencies;
}
 
Example #6
Source File: ShrinkwrapArtifactResolvingHelper.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public Set<ArtifactSpec> resolveAll(final Collection<ArtifactSpec> specs, boolean transitive, boolean defaultExcludes) {
    if (specs.isEmpty()) {
        return Collections.emptySet();
    }

    final Set<ArtifactSpec> resolvedSpecs = new HashSet<>();
    // If we don't need transitive dependencies, then perform a dependency resolution only for the artifacts that do not have
    // a file reference.
    if (!transitive) {
        specs.stream().filter(s -> s.file != null).forEach(resolvedSpecs::add);
        specs.removeAll(resolvedSpecs);
        if (specs.isEmpty()) {
            return resolvedSpecs;
        }
    }

    MavenResolutionStrategy transitivityStrategy = (transitive ? TransitiveStrategy.INSTANCE : NonTransitiveStrategy.INSTANCE);

    resetListeners();
    final MavenResolvedArtifact[] artifacts =
            withResolver(r -> {
                specs.forEach(spec -> r.addDependency(createMavenDependency(spec)));
                return r.resolve()
                        .using(transitivityStrategy)
                        .as(MavenResolvedArtifact.class);
            });

    resolvedSpecs.addAll(
            Arrays.stream(artifacts).map(artifact -> {
                final MavenCoordinate coord = artifact.getCoordinate();
                return new ArtifactSpec(artifact.getScope().toString(),
                                        coord.getGroupId(),
                                        coord.getArtifactId(),
                                        coord.getVersion(),
                                        coord.getPackaging().getId(),
                                        coord.getClassifier(),
                                        artifact.asFile());
            }).collect(Collectors.toSet())
    );
    return resolvedSpecs;
}
 
Example #7
Source File: ShrinkwrapArtifactResolvingHelper.java    From thorntail with Apache License 2.0 votes vote down vote up
MavenResolvedArtifact[] resolve(ConfigurableMavenResolverSystem resolver); 
Example #8
Source File: ShrinkwrapArtifactResolvingHelper.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 votes vote down vote up
MavenResolvedArtifact[] resolve(ConfigurableMavenResolverSystem resolver);