Search in sources :

Example 1 with DependencyResolver

use of org.apache.storm.submit.dependency.DependencyResolver in project storm by apache.

the class DependencyResolverMain method main.

public static void main(String[] args) {
    if (args.length < 1) {
        throw new IllegalArgumentException("artifacts must be presented.");
    }
    String artifactsArg = args[0];
    // DO NOT CHANGE THIS TO SYSOUT
    System.err.println("DependencyResolver input - artifacts: " + artifactsArg);
    List<Dependency> dependencies = parseArtifactArgs(artifactsArg);
    List<RemoteRepository> repositories;
    if (args.length > 1) {
        String remoteRepositoryArg = args[1];
        // DO NOT CHANGE THIS TO SYSOUT
        System.err.println("DependencyResolver input - repositories: " + remoteRepositoryArg);
        repositories = parseRemoteRepositoryArgs(remoteRepositoryArg);
    } else {
        repositories = Collections.emptyList();
    }
    try {
        String localMavenRepoPath = getOrDefaultLocalMavenRepositoryPath("local-repo");
        DependencyResolver resolver = new DependencyResolver(localMavenRepoPath, repositories);
        List<ArtifactResult> artifactResults = resolver.resolve(dependencies);
        Iterable<ArtifactResult> missingArtifacts = filterMissingArtifacts(artifactResults);
        if (missingArtifacts.iterator().hasNext()) {
            printMissingArtifactsToSysErr(missingArtifacts);
            throw new RuntimeException("Some artifacts are not resolved");
        }
        System.out.println(JSONValue.toJSONString(transformArtifactResultToArtifactToPaths(artifactResults)));
        System.out.flush();
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Dependency(org.sonatype.aether.graph.Dependency) DependencyResolver(org.apache.storm.submit.dependency.DependencyResolver) ArtifactResult(org.sonatype.aether.resolution.ArtifactResult)

Aggregations

DependencyResolver (org.apache.storm.submit.dependency.DependencyResolver)1 Dependency (org.sonatype.aether.graph.Dependency)1 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)1 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)1