Package org.sonatype.aether.util.artifact

Examples of org.sonatype.aether.util.artifact.DefaultArtifact


    public void execute() throws MojoExecutionException, MojoFailureException {
        try {
//            FindAvailableVersions.main(null);
            initialize();

            Artifact artifact = new DefaultArtifact(artifactName);
            ArtifactResults2 artifactResults = resolveArtifact(artifact);

            artifact = artifactResults.artifact;

            List<ArtifactResult> dependencies = artifactResults.getDependencies();

            if(className != null){
                new ExecObject2(getLog(),
                    artifact, dependencies, className,
                    parseArgs(),
                    systemProperties
                ).execute();
            }

            Class<?> installation = new URLClassLoader(new URL[]{artifact.getFile().toURI().toURL()}).loadClass("Installation");

            List<Object[]> entries = (List<Object[]>) OpenBean2.getStaticFieldValue(installation, "shortcuts");

            if(installTo == null){
               installTo = findPath();
View Full Code Here


      }
   }

   public Artifact dependencyToMavenArtifact(final Dependency dep)
   {
      Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(),
               dep.getPackagingType() == null ? "jar" : dep.getPackagingType(), dep.getVersion());
      return artifact;
   }
View Full Code Here

        return resolve(groupId, artifactId, version, extension, "");
    }

    public AetherResult resolve(String groupId, String artifactId, String version, String extension, String classifier) throws DependencyCollectionException, ArtifactResolutionException, DependencyResolutionException {
        RepositorySystemSession session = newSession();
        Dependency dependency = new Dependency(new DefaultArtifact(groupId, artifactId, classifier, extension, version), "runtime");

        CollectRequest collectRequest = new CollectRequest();
        collectRequest.setRoot(dependency);
        for (Repository repo: remoteRepos) {
            collectRequest.addRepository(repo.toRemoteRepository());
View Full Code Here

    protected String extension = "jar";
    protected String classifier = "";

    @Test
    public void testArchetypeResolve() throws Exception {
        Artifact artifact = new DefaultArtifact(groupId, artifactId, "jar", version);
        File file = mavenResolver.resolveFile(artifact);
        assertNotNull("File null for " + artifact, file);
        assertTrue("File should exist for " + artifact, file.exists());
    }
View Full Code Here

     * @param path The request path, following the format: {@code <groupId>/<artifactId>/<version>/<artifactId>-<version>-[<classifier>].extension}
     * @return A {@link DefaultArtifact} that matches the request path.
     * @throws InvalidMavenArtifactRequest
     */
    protected Artifact convertPathToArtifact(String path) throws InvalidMavenArtifactRequest {
        return new DefaultArtifact(convertToMavenUrl(path), null);
    }
View Full Code Here

        MavenRepositorySystemSession session = createSession(offline, repo);

        List<RemoteRepository> repos = getRemoteRepositories();

        Map<String,String> props = Collections.singletonMap(ArtifactProperties.LOCAL_PATH, rootPom.toString());
        Artifact root = new DefaultArtifact("#groupId", "#artifactId", null, "pom", "#version", props, rootPom);

        ArtifactDescriptorResult artifactDescriptorResult = repo.readArtifactDescriptor(session, new ArtifactDescriptorRequest(root, repos, null));

        CollectRequest request = new CollectRequest( artifactDescriptorResult.getDependencies(), null, repos );
        DependencyFilter filter = new AndDependencyFilter();
View Full Code Here

    public Artifact resolveArtifact(boolean offline, String groupId, String artifactId, String version, String classifier, String extension) throws ArtifactResolutionException {
        RepositorySystem repo = getRepositorySystem();
        MavenRepositorySystemSession session = createSession(offline, repo);


        Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version);
        List<RemoteRepository> repos = getRemoteRepositories();

        ArtifactRequest request = new ArtifactRequest(artifact,  repos,  null);
        ArtifactResult result = repo.resolveArtifact(session, request);
        return result.getArtifact();
View Full Code Here

        String pomVersion = model.getVersion();
        String packaging = "pom";
        if (groupId == null || artifactId == null || pomVersion == null) {
            throw new IllegalArgumentException("Pomegranate pom.xml has missing groupId:artifactId:version " + groupId + ":" + artifactId + ":" + pomVersion);
        }
        Artifact root = new DefaultArtifact(groupId, artifactId, null, packaging, pomVersion, props, rootPom);

        return collectDependencies(root, pomVersion, offline, excludeDependencyFilter);
    }
View Full Code Here

    public DependencyTreeResult collectDependencies(VersionedDependencyId dependencyId, boolean offline, Filter<Dependency> excludeDependencyFilter) throws RepositoryException, IOException {
        return collectDependencies(dependencyId.getGroupId(), dependencyId.getArtifactId(), dependencyId.getVersion(), dependencyId.getExtension(), dependencyId.getClassifier(), offline, excludeDependencyFilter);
    }

    public DependencyTreeResult collectDependencies(String groupId, String artifactId, String version, String extension, String classifier, boolean offline, Filter<Dependency> excludeDependencyFilter) throws RepositoryException, IOException {
        DefaultArtifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version);
        return collectDependencies(artifact, version, offline, excludeDependencyFilter);
    }
View Full Code Here

        // Add extraWars into the jar
        if (extraWars != null) {
          for (Dependency extraWarDependency : extraWars) {
            ArtifactRequest request = new ArtifactRequest();
            request.setArtifact(new DefaultArtifact(extraWarDependency.getGroupId(), extraWarDependency
                .getArtifactId(), extraWarDependency.getType(), extraWarDependency.getVersion()));

            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("ecj: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()));

            ArtifactResult result;
            try {
              result = repoSystem.resolveArtifact(repoSession, request);
View Full Code Here

TOP

Related Classes of org.sonatype.aether.util.artifact.DefaultArtifact

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.