org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency Java Examples

The following examples show how to use org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency. 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: Dependencies.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
public static URL[] resolve(final MavenDependency dep) {
    return CACHE.computeIfAbsent(dep, d -> {
        final ConfigurableMavenResolverSystem resolver = Maven
                .configureResolver()
                .withClassPathResolution(true)
                .workOffline(Boolean.getBoolean("talend.component.junit.maven.offline"));
        REPOSITORIES.forEach(resolver::withRemoteRepo);
        resolver.addDependency(dep);
        return Stream.of(resolver.resolve().using(STRATEGY).asFile()).distinct().map(f -> {
            try {
                return f.toURI().toURL();
            } catch (final MalformedURLException e) {
                throw new IllegalStateException(e);
            }
        }).toArray(URL[]::new);
    });
}
 
Example #2
Source File: Resolver.java    From arquillian-container-chameleon with Apache License 2.0 6 votes vote down vote up
public static File[] resolve(File cacheFolder, MavenDependency[] dependencies) {
    String hash = hash(dependencies);
    File[] files;

    File cacheFile = getCacheFile(cacheFolder, hash);
    if (cacheFile.exists()) {
        files = readCache(cacheFile);
    } else {
        files = Maven.configureResolver()
            .addDependencies(dependencies)
            .resolve()
            .withTransitivity()
            .asFile();

        writeCache(getCacheFile(cacheFolder, hash), files);
    }
    return files;
}
 
Example #3
Source File: ShrinkwrapArtifactResolvingHelper.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public MavenDependency createMavenDependency(final ArtifactSpec spec) {
    final MavenCoordinate newCoordinate = MavenCoordinates.createCoordinate(
            spec.groupId(),
            spec.artifactId(),
            spec.version(),
            PackagingType.of(spec.type()),
            spec.classifier());
    return MavenDependencies.createDependency(newCoordinate, ScopeType.fromScopeType(spec.scope), false);
}
 
Example #4
Source File: TargetController.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
private ClassLoader resolveClasspathDependencies(ContainerAdapter targetAdapter, File resolverCacheFolder) {
    String[] dependencies = targetAdapter.dependencies();

    try {
        MavenDependency[] mavenDependencies = toMavenDependencies(dependencies, targetAdapter.excludes());

        File[] archives = Resolver.resolve(resolverCacheFolder, mavenDependencies);
        return new URLClassLoader(toURLs(archives), ChameleonContainer.class.getClassLoader());
    } catch (Exception e) {
        throw new RuntimeException("Could not resolve target " + targetAdapter + " adapter dependencies", e);
    }
}
 
Example #5
Source File: ContainerLoader.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
public Container[] load(InputStream containers, File cacheFolder) throws Exception {

        MavenDependency[] mavenDependencies = Utils.toMavenDependencies(
            new String[] {"org.yaml:snakeyaml:1.24"},
            new String[] {});

        File[] archives = Resolver.resolve(cacheFolder, mavenDependencies);

        ClassLoader classloader = new URLClassLoader(Utils.toURLs(archives), null);
        return loadContainers(classloader, containers);
    }
 
Example #6
Source File: Utils.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
public static MavenDependency[] toMavenDependencies(String[] dependencies, String[] exclusions) {
    MavenDependencyExclusion[] mavenExclusions = toMavenExclusions(exclusions);
    MavenDependency[] mavenDependencies = new MavenDependency[dependencies.length];
    for (int i = 0; i < dependencies.length; i++) {
        mavenDependencies[i] = MavenDependencies.createDependency(
            dependencies[i],
            ScopeType.COMPILE,
            false,
            mavenExclusions);
    }
    return mavenDependencies;
}
 
Example #7
Source File: WebArchiveBuilder.java    From krazo with Apache License 2.0 4 votes vote down vote up
public WebArchiveBuilder addDependencies(MavenDependency... dependencies) {
    this.additionalDependencies.addAll(Arrays.asList(dependencies));
    return this;
}
 
Example #8
Source File: BeamEnvironment.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
@Override
protected MavenDependency[] rootDependencies() {
    return new MavenDependency[] { getRunnerDependency(), getComponentRuntimeBeamDependency() };
}
 
Example #9
Source File: BeamEnvironment.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
protected MavenDependency getRunnerDependency() {
    return createDependency(rootDependencyBase() + ":jar:" + beamVersion, RUNTIME, false);
}
 
Example #10
Source File: BeamEnvironment.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
protected MavenDependency getComponentRuntimeBeamDependency() {
    return createDependency("org.talend.sdk.component:component-runtime-beam:jar:" + kitVersion, RUNTIME, false);
}
 
Example #11
Source File: WebArchiveBuilder.java    From ozark with Apache License 2.0 4 votes vote down vote up
public WebArchiveBuilder addDependencies(MavenDependency... dependencies) {
    this.additionalDependencies.addAll(Arrays.asList(dependencies));
    return this;
}
 
Example #12
Source File: ClassLoaderEnvironment.java    From component-runtime with Apache License 2.0 votes vote down vote up
protected abstract MavenDependency[] rootDependencies();