当前位置: 首页>>代码示例>>Java>>正文


Java DependencyResolutionException类代码示例

本文整理汇总了Java中org.sonatype.aether.resolution.DependencyResolutionException的典型用法代码示例。如果您正苦于以下问题:Java DependencyResolutionException类的具体用法?Java DependencyResolutionException怎么用?Java DependencyResolutionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DependencyResolutionException类属于org.sonatype.aether.resolution包,在下文中一共展示了DependencyResolutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fetch

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
 * fetch all artifacts
 * @return
 * @throws MalformedURLException
 * @throws ArtifactResolutionException
 * @throws DependencyResolutionException
 */
public List<File> fetch() throws MalformedURLException,
    DependencyResolutionException, ArtifactResolutionException {

  for (Dependency dep : dependencies) {
    if (!dep.isLocalFsArtifact()) {
      List<ArtifactResult> artifacts = fetchArtifactWithDep(dep);
      for (ArtifactResult artifact : artifacts) {
        if (dep.isDist()) {
          filesDist.add(artifact.getArtifact().getFile());
        }
        files.add(artifact.getArtifact().getFile());
      }
    } else {
      if (dep.isDist()) {
        filesDist.add(new File(dep.getGroupArtifactVersion()));
      }
      files.add(new File(dep.getGroupArtifactVersion()));
    }
  }

  return files;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:30,代码来源:DependencyContext.java

示例2: fetchArtifactWithDep

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep)
    throws DependencyResolutionException, ArtifactResolutionException {
  Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());

  DependencyFilter classpathFilter = DependencyFilterUtils
      .classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(
      dep.getExclusions());

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact,
      JavaScopes.COMPILE));

  collectRequest.addRepository(mavenCentral);
  collectRequest.addRepository(mavenLocal);
  for (Repository repo : repositories) {
    RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
    rr.setPolicy(repo.isSnapshot(), null);
    collectRequest.addRepository(rr);
  }

  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));

  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:DependencyContext.java

示例3: getArtifactsWithDep

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
  Collection<String> excludes) throws RepositoryException {
  Artifact artifact = new DefaultArtifact(dependency);
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
          new PatternExclusionsDependencyFilter(excludes);

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
          DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  try {
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
  } catch (NullPointerException | DependencyResolutionException ex) {
    throw new RepositoryException(
            String.format("Cannot fetch dependencies for %s", dependency), ex);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:32,代码来源:DependencyResolver.java

示例4: installBundlesFromArtifacts

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private List<Bundle> installBundlesFromArtifacts(List<ArtifactResult> artifactResults) throws BundleException, IOException, DependencyResolutionException {
    List<Bundle> bundlesInstalled = new LinkedList<>();
    for (ArtifactResult artifact : artifactResults) {
        if (isOSGiFramework(artifact)) {
            // skip the framework jar
            continue;
        }

        LOGGER.info("Installing " + artifact);
        final File dependencyBundleFile = artifact.getArtifact().getFile();

        final Bundle bundle = installBundleFromFile(dependencyBundleFile, false, true);
        if (bundle != null) {
            bundlesInstalled.add(bundle);
        }
    }
    return bundlesInstalled;
}
 
开发者ID:motech,项目名称:motech,代码行数:19,代码来源:ModuleAdminServiceImpl.java

示例5: resolveArtifacts

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private List<Artifact> resolveArtifacts(DependencyRequest dependencyRequest)
{
    DependencyResult dependencyResult;
    try {
        dependencyResult = repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
    }
    catch (DependencyResolutionException e) {
        dependencyResult = e.getResult();
    }
    List<ArtifactResult> artifactResults = dependencyResult.getArtifactResults();
    List<Artifact> artifacts = new ArrayList<>(artifactResults.size());
    for (ArtifactResult artifactResult : artifactResults) {
        if (artifactResult.isMissing()) {
            artifacts.add(artifactResult.getRequest().getArtifact());
        }
        else {
            artifacts.add(artifactResult.getArtifact());
        }
    }

    return Collections.unmodifiableList(artifacts);
}
 
开发者ID:airlift,项目名称:resolver,代码行数:23,代码来源:ArtifactResolver.java

示例6: toString

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String toString() {
    final StringBuilder text = new StringBuilder();
    text.append(
        Logger.format(
            "%s:%s:%s:%d",
            this.art.getGroupId(),
            this.art.getArtifactId(),
            this.art.getVersion(),
            this.exclusions.size()
        )
    );
    try {
        for (final Artifact child : this.children()) {
            text.append("\n  ").append(child);
            if (this.excluded(child)) {
                text.append(" (excluded)");
            }
        }
    } catch (final DependencyResolutionException ex) {
        text.append(' ').append(ex);
    }
    return text.toString();
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:28,代码来源:RootArtifact.java

示例7: resolve

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
 * List of transitive dependencies of the artifact.
 * @param root The artifact to work with
 * @param scope The scope to work with ("runtime", "test", etc.)
 * @param filter The dependency filter to work with
 * @return The list of dependencies
 * @throws DependencyResolutionException If can't fetch it
 */
public List<Artifact> resolve(final Artifact root,
    final String scope, final DependencyFilter filter)
    throws DependencyResolutionException {
    final List<Artifact> deps = new LinkedList<Artifact>();
    final RepositorySystem system = new RepositorySystemBuilder().build();
    deps.addAll(
        this.fetch(
            system,
            this.session(system),
            new DependencyRequest(
                this.request(new Dependency(root, scope)),
                filter
            )
        )
    );
    return deps;
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:26,代码来源:Aether.java

示例8: interpret

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
  PrintStream printStream = new PrintStream(out);
  Console.setOut(printStream);
  out.reset();

  SparkInterpreter sparkInterpreter = getSparkInterpreter();

  if (sparkInterpreter != null && sparkInterpreter.isSparkContextInitialized()) {
    return new InterpreterResult(Code.ERROR,
        "Must be used before SparkInterpreter (%spark) initialized\n" +
        "Hint: put this paragraph before any Spark code and " +
        "restart Zeppelin/Interpreter" );
  }

  scala.tools.nsc.interpreter.Results.Result ret = intp.interpret(st);
  Code code = getResultCode(ret);

  try {
    depc.fetch();
  } catch (MalformedURLException | DependencyResolutionException
      | ArtifactResolutionException e) {
    return new InterpreterResult(Code.ERROR, e.toString());
  }

  if (code == Code.INCOMPLETE) {
    return new InterpreterResult(code, "Incomplete expression");
  } else if (code == Code.ERROR) {
    return new InterpreterResult(code, out.toString());
  } else {
    return new InterpreterResult(code, out.toString());
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:34,代码来源:DepInterpreter.java

示例9: interpret

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
  PrintStream printStream = new PrintStream(out);
  Console.setOut(printStream);
  out.reset();

  SparkInterpreter sparkInterpreter = getSparkInterpreter();

  if (sparkInterpreter != null && sparkInterpreter.isSparkContextInitialized()) {
    return new InterpreterResult(Code.ERROR,
        "Must be used before SparkInterpreter (%spark) initialized\n" +
        "Hint: put this paragraph before any Spark code and " +
        "restart Zeppelin/Interpreter" );
  }

  scala.tools.nsc.interpreter.Results.Result ret = interpret(st);
  Code code = getResultCode(ret);

  try {
    depc.fetch();
  } catch (MalformedURLException | DependencyResolutionException
      | ArtifactResolutionException e) {
    LOGGER.error("Exception in DepInterpreter while interpret ", e);
    return new InterpreterResult(Code.ERROR, e.toString());
  }

  if (code == Code.INCOMPLETE) {
    return new InterpreterResult(code, "Incomplete expression");
  } else if (code == Code.ERROR) {
    return new InterpreterResult(code, out.toString());
  } else {
    return new InterpreterResult(code, out.toString());
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:35,代码来源:DepInterpreter.java

示例10: loadInternal

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private static void loadInternal(@NotNull Artifact artifact, @NotNull JarFileLoader jarFileClassLoader) throws
                                                                                                   DependencyResolutionException {
        if (!dollarLib.exists()) {
            if (!dollarLib.mkdirs()) {
                log.error("Could not create the ~/.dollar directory");
                System.exit(-1);
            }
        }
        Collection<RemoteRepository> remotes = Collections.singletonList(
                new RemoteRepository(
                                            "maven-central",
                                            "default",
                                            "http://repo1.maven.org/maven2/"
                )
        );
//        final Aether aether = new Aether(remotes, dollarLib);
////        new DefaultArtifact("junit", "junit-dep", "", "jar", "4.10")
//        Collection<Artifact> deps = aether.resolve(artifact
//                , "runtime"
//        );
//        for (Artifact dep : deps) {
//            try {
//                jarFileClassLoader.addFile(dep.getFile().getAbsolutePath());
//            } catch (MalformedURLException e) {
//                e.printStackTrace();
//            }
//        }
    }
 
开发者ID:sillelien,项目名称:dollar,代码行数:29,代码来源:DependencyRetriever.java

示例11: retrieve

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
@NotNull public static JarFileLoader retrieve(@NotNull List<String> artifacts) throws
                                                                               DependencyResolutionException {
    JarFileLoader jarFileClassLoader = new JarFileLoader(new URL[]{});
    for (String artifact : artifacts) {
        loadInternal(new DefaultArtifact(artifact), jarFileClassLoader);
    }
    return jarFileClassLoader;
}
 
开发者ID:sillelien,项目名称:dollar,代码行数:9,代码来源:DependencyRetriever.java

示例12: testResolvePom

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
@Test
public void testResolvePom()
        throws DependencyResolutionException
{
    File pomFile = new File("src/test/poms/maven-core-3.0.4.pom");
    Assert.assertTrue(pomFile.canRead());

    ArtifactResolver artifactResolver = new ArtifactResolver(USER_LOCAL_REPO, MAVEN_CENTRAL_URI);
    List<Artifact> artifacts = artifactResolver.resolvePom(pomFile);

    Assert.assertNotNull(artifacts, "artifacts is null");
    for (Artifact artifact : artifacts) {
        Assert.assertNotNull(artifact.getFile(), "Artifact " + artifact + " is not resolved");
    }
}
 
开发者ID:airlift,项目名称:resolver,代码行数:16,代码来源:ArtifactResolverTest.java

示例13: main

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
public static void main(String[] args) throws DependencyResolutionException {
    Injector injector = Guice.createInjector(
        new RepositorySystemModule() {
            @Override
            public List<RemoteRepository> getRemoteRepositories(ExtensionList<RemoteRepositoryDecorator> decorators) {
                try {
                    List<RemoteRepository> repos = super.getRemoteRepositories(decorators);

                    // use our real local repository as one of the remote repositories,
                    // so that this process runs quickly.
                    File local = new File(new File(System.getProperty("user.home")), ".m2/repository");
                    repos.add(0,new RemoteRepository("local","default",local.toURL().toExternalForm()));

                    repos.add(new RemoteRepository("repo.jenkins-ci.org","default","http://repo.jenkins-ci.org/public/"));
                    return repos;
                } catch (MalformedURLException e) {
                    throw new Error(e);
                }
            }
        }
    );

    // we tell Aether that our local repository is elsewhere, so that we can capture everything
    File dir = new File(args[0]);
    dir.mkdirs();
    injector.getInstance(LocalRepositorySetting.class).set(
            new LocalRepository(dir));

    // resolve away
    RepositoryService rs = injector.getInstance(RepositoryService.class);
    DependencyResult result = rs.resolveDependencies(
            new GAV(BeesLoader.MAIN.groupId, BeesLoader.MAIN.artifactId, args[1]));

    // generate maven-metadata.xml files. necessary for resolving LATEST version label.
    for (ArtifactResult ar : result.getArtifactResults()) {
        writeMetadata(ar.getArtifact(),dir);
    }
}
 
开发者ID:ndeloof,项目名称:bees-cli-bootstrap,代码行数:39,代码来源:Assembler.java

示例14: children

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
 * Get all dependencies of this root artifact.
 * @return The list of artifacts
 * @throws DependencyResolutionException If fails to resolve
 */
@Cacheable(forever = true)
public Collection<Artifact> children()
    throws DependencyResolutionException {
    return this.aether.resolve(
        this.art, JavaScopes.COMPILE, new NonOptionalFilter()
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:13,代码来源:RootArtifact.java

示例15: fetch

import org.sonatype.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
 * Fetch dependencies.
 * Catch of NPE is required because sonatype even when it can't resolve
 * given artifact tries to get its root and execute a method on it,
 * which is not possible and results in NPE. Moreover sonatype library
 * is not developed since 2011 so this bug won't be fixed.
 * @param system The repository system
 * @param session The session
 * @param dreq Dependency request
 * @return The list of dependencies
 * @throws DependencyResolutionException If can't fetch it
 */
@SuppressWarnings("PMD.AvoidCatchingGenericException")
private List<Artifact> fetch(final RepositorySystem system,
    final RepositorySystemSession session, final DependencyRequest dreq)
    throws DependencyResolutionException {
    final List<Artifact> deps = new LinkedList<Artifact>();
    try {
        Collection<ArtifactResult> results;
        synchronized (this.lrepo) {
            results = system.resolveDependencies(session, dreq)
                .getArtifactResults();
        }
        for (final ArtifactResult res : results) {
            deps.add(res.getArtifact());
        }
    // @checkstyle IllegalCatch (1 line)
    } catch (final Exception ex) {
        throw new DependencyResolutionException(
            new DependencyResult(dreq),
            new IllegalArgumentException(
                Logger.format(
                    "failed to load '%s' from %[list]s into %s",
                    dreq.getCollectRequest().getRoot(),
                    Aether.reps(dreq.getCollectRequest().getRepositories()),
                    session.getLocalRepositoryManager()
                        .getRepository()
                        .getBasedir()
                ),
                ex
            )
        );
    }
    return deps;
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:46,代码来源:Aether.java


注:本文中的org.sonatype.aether.resolution.DependencyResolutionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。