Package org.sonatype.aether.resolution

Examples of org.sonatype.aether.resolution.ArtifactResult


        request.setRepositories(projectRepos);

        getLog().debug("Resolving artifact " + artifact +
                " from " + projectRepos);

        ArtifactResult result;
        try {
            result = repoSystem.resolveArtifact(repoSession, request);
        } catch (org.sonatype.aether.resolution.ArtifactResolutionException e) {
            getLog().warn("could not resolve " + artifact, e);
            return null;
        }

        getLog().debug("Resolved artifact " + artifact + " to " +
                result.getArtifact().getFile() + " from "
                + result.getRepository());
        return result.getArtifact().getFile();
    }
View Full Code Here


               request.addRepository(remoteRepo);
               request.setArtifact(artifact);

               try
               {
                  ArtifactResult a = system.resolveArtifact(session, request);

                  File file = a.getArtifact().getFile();
                  DependencyResource resource = new DependencyResource(factory, file, currentVersion);
                  if (!result.contains(resource))
                  {
                     result.add(resource);
                     continue VERSION;
View Full Code Here

    request.setRepositories(remoteRepoList);

    try {

      final ArtifactResult result = //
      repoSystem.resolveArtifact(repoSession, request);

      return result.isResolved();

    } catch (final ArtifactResolutionException e) {

      getLog().warn("missing artifact : " + artifact);
View Full Code Here

    request.setRepositories(remoteRepoList);

    try {

      final ArtifactResult result = //
      repoSystem.resolveArtifact(repoSession, request);

      if (result.isResolved()) {
        return result.getArtifact();
      }

    } catch (final ArtifactResolutionException e) {

      getLog().warn("missing artifact : " + artifact);
View Full Code Here

          for (Dependency extraWarDependency : extraWars) {
            ArtifactRequest request = new ArtifactRequest();
            request.setArtifact(new DefaultArtifact(extraWarDependency.getGroupId(), extraWarDependency
                .getArtifactId(), extraWarDependency.getType(), extraWarDependency.getVersion()));
            request.setRepositories(projectRepos);
            ArtifactResult result;
            try {
              result = repoSystem.resolveArtifact(repoSession, request);
            } catch (ArtifactResolutionException e) {
              throw new MojoExecutionException(e.getMessage(), e);
            }

            File extraWarFile = result.getArtifact().getFile();
            aos.putArchiveEntry(new JarArchiveEntry(extraWarFile.getName()));
            try (InputStream is = Files.newInputStream(extraWarFile.toPath())) {
              IOUtils.copy(is, aos);
            }
            aos.closeArchiveEntry();

          }
        }

        // Add extraResources into the jar. Folder /extra
        if (extraResources != null) {
          for (Resource extraResource : extraResources) {
            DirectoryScanner directoryScanner = new DirectoryScanner();
            directoryScanner.setBasedir(extraResource.getDirectory());

            directoryScanner.setExcludes(extraResource.getExcludes().toArray(
                new String[extraResource.getExcludes().size()]));

            if (!extraResource.getIncludes().isEmpty()) {
              directoryScanner.setIncludes(extraResource.getIncludes().toArray(
                  new String[extraResource.getIncludes().size()]));
            } else {
              // include everything by default
              directoryScanner.setIncludes(new String[] { "**" });
            }

            directoryScanner.scan();
            for (String includeFile : directoryScanner.getIncludedFiles()) {
              aos.putArchiveEntry(new JarArchiveEntry(Runner.EXTRA_RESOURCES_DIR + "/" + includeFile));

              Path extraFile = Paths.get(extraResource.getDirectory(), includeFile);
              try (InputStream is = Files.newInputStream(extraFile)) {
                IOUtils.copy(is, aos);
              }
              aos.closeArchiveEntry();
            }

          }
        }

        Set<String> includeArtifacts = new HashSet<>();
        includeArtifacts.add("org.apache.tomcat:tomcat-jdbc");
        includeArtifacts.add("org.apache.tomcat.embed:tomcat-embed-core");
        includeArtifacts.add("org.apache.tomcat.embed:tomcat-embed-logging-juli");
        includeArtifacts.add("org.yaml:snakeyaml");
        includeArtifacts.add("com.beust:jcommander");

        if (includeJSPSupport) {
          includeArtifacts.add("org.apache.tomcat.embed:tomcat-embed-jasper");
          includeArtifacts.add("org.eclipse.jdt.core.compiler:ecj");
        }

        for (Artifact pluginArtifact : pluginArtifacts) {
          String artifactName = pluginArtifact.getGroupId() + ":" + pluginArtifact.getArtifactId();
          if (includeArtifacts.contains(artifactName)) {
            try (JarFile jarFile = new JarFile(pluginArtifact.getFile())) {
              extractJarToArchive(jarFile, aos);
            }
          }
        }

        if (extraDependencies != null) {
          for (Dependency dependency : extraDependencies) {

            ArtifactRequest request = new ArtifactRequest();
            request.setArtifact(new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(),
                dependency.getType(), dependency.getVersion()));
            request.setRepositories(projectRepos);
            ArtifactResult result;
            try {
              result = repoSystem.resolveArtifact(repoSession, request);
            } catch (ArtifactResolutionException e) {
              throw new MojoExecutionException(e.getMessage(), e);
            }

            try (JarFile jarFile = new JarFile(result.getArtifact().getFile())) {
              extractJarToArchive(jarFile, aos);
            }
          }
        }

View Full Code Here

        ArtifactRequest artifactRequest = new ArtifactRequest();
        artifactRequest.setArtifact(artifact);
        artifactRequest.addRepository(central);

        ArtifactResult artifactResult;
        try {
            artifactResult = REPOSITORY_SYSTEM.resolveArtifact(session, artifactRequest);
        } catch(ArtifactResolutionException e) {
            throw new RuntimeException(e);
        }

        File file = artifactResult.getArtifact().getFile().getAbsoluteFile();
        System.out.println(file);
        return file.toURI().toURL();
    }
View Full Code Here

        ArtifactRequest artifactRequest = new ArtifactRequest();
        artifactRequest.setArtifact(artifact);
        artifactRequest.addRepository(central);

        ArtifactResult artifactResult;
        try {
            artifactResult = REPOSITORY_SYSTEM.resolveArtifact(session, artifactRequest);
        } catch(ArtifactResolutionException e) {
            throw new RuntimeException(e);
        }

        List<URL> urls = new ArrayList<URL>();
        urls.add(artifactToUrl(artifactResult.getArtifact()));

        CollectRequest collectRequest = new CollectRequest();
        collectRequest.setRoot(new Dependency(artifact, "compile" ));
        collectRequest.addRepository( central );
        DependencyNode node = REPOSITORY_SYSTEM.collectDependencies( session, collectRequest ).getRoot();
View Full Code Here

               request.addRepository(remoteRepo);
               request.setArtifact(artifact);

               try
               {
                  ArtifactResult a = system.resolveArtifact(session, request);

                  File file = a.getArtifact().getFile();
                  DependencyResource resource = new DependencyResource(factory, file, currentVersion);
                  if (!result.contains(resource))
                  {
                     result.add(resource);
                     continue VERSION;
View Full Code Here

    request.setRepositories(remoteRepoList);

    try {

      final ArtifactResult result = //
      repoSystem.resolveArtifact(repoSession, request);

      return result.isResolved();

    } catch (final ArtifactResolutionException e) {

      getLog().warn("missing artifact : " + artifact);
View Full Code Here

    request.setRepositories(remoteRepoList);

    try {

      final ArtifactResult result = //
      repoSystem.resolveArtifact(repoSession, request);

      if (result.isResolved()) {
        return result.getArtifact();
      }

    } catch (final ArtifactResolutionException e) {

      getLog().warn("missing artifact : " + artifact);
View Full Code Here

TOP

Related Classes of org.sonatype.aether.resolution.ArtifactResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.