Examples of Artifact


Examples of org.apache.maven.artifact.Artifact

        throws ArtifactResolutionException, ArtifactNotFoundException
    {
        String file = null;
        if (dependency != null)
        {
            final Artifact artifact =
                this.factory.createArtifact(
                    dependency.getGroupId(),
                    dependency.getArtifactId(),
                    dependency.getVersion(),
                    null,
                    dependency.getType());

            this.artifactResolver.resolve(
                artifact,
                project.getRemoteArtifactRepositories(),
                this.localRepository);
            file = artifact.getFile() != null ? artifact.getFile().toString() : null;
        }
        return file;
    }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

        final Set projectArtifactIds = new LinkedHashSet();
        for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            final Artifact projectArtifact =
                artifactFactory.createArtifact(
                    project.getGroupId(),
                    project.getArtifactId(),
                    project.getVersion(),
                    null,
                    project.getPackaging());
            projectArtifactIds.add(projectArtifact.getId());
        }

        // - write the source roots for the root project (if they are any)
        this.writeSourceRoots(this.project, rootDirectory, writer);

        final Set allArtifacts = new LinkedHashSet(this.project.createArtifacts(
            artifactFactory,
            null,
            null));
        for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            this.writeSourceRoots(project, rootDirectory, writer);
            final Set artifacts = project.createArtifacts(
                    artifactFactory,
                    null,
                    null);

            // - get the direct dependencies
            for (final Iterator artifactIterator = artifacts.iterator(); artifactIterator.hasNext();)
            {
                final Artifact artifact = (Artifact)artifactIterator.next();

                // - don't attempt to resolve the artifact if its part of the project (we
                //   infer this if it has the same id has one of the projects or is in
                //   the same groupId).
                if (!projectArtifactIds.contains(artifact.getId()) &&
                    !project.getGroupId().equals(artifact.getGroupId()))
                {
                    artifactResolver.resolve(
                        artifact,
                        project.getRemoteArtifactRepositories(),
                        localRepository);
                    allArtifacts.add(artifact);
                }
                else
                {
                    allArtifacts.add(artifact);
                }
            }
        }

        // - remove the project artifacts
        for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            final Artifact projectArtifact = project.getArtifact();
            if (projectArtifact != null)
            {
                for (final Iterator artifactIterator = allArtifacts.iterator(); artifactIterator.hasNext();)
                {
                    final Artifact artifact = (Artifact)artifactIterator.next();
                    final String projectId = projectArtifact.getArtifactId();
                    final String projectGroupId = projectArtifact.getGroupId();
                    final String artifactId = artifact.getArtifactId();
                    final String groupId = artifact.getGroupId();
                    if (artifactId.equals(projectId) && groupId.equals(projectGroupId))
                    {
                        artifactIterator.remove();
                    }
                }
            }
        }

        // - now we resolve transitively, if we have the flag on
        if (resolveTransitiveDependencies)
        {
            final Artifact rootProjectArtifact =
                artifactFactory.createArtifact(
                    this.project.getGroupId(),
                    this.project.getArtifactId(),
                    this.project.getVersion(),
                    null,
                    this.project.getPackaging());

            final OrArtifactFilter filter = new OrArtifactFilter();
            filter.add(new ScopeArtifactFilter(Artifact.SCOPE_COMPILE));
            filter.add(new ScopeArtifactFilter(Artifact.SCOPE_PROVIDED));
            filter.add(new ScopeArtifactFilter(Artifact.SCOPE_TEST));
            final ArtifactResolutionResult result =
                artifactResolver.resolveTransitively(
                    allArtifacts,
                    rootProjectArtifact,
                    localRepository,
                    remoteRepositories,
                    artifactMetadataSource,
                    filter);

            allArtifacts.clear();
            allArtifacts.addAll(result.getArtifacts());
        }

        final List allArtifactPaths = new ArrayList(allArtifacts);
        for (final ListIterator iterator = allArtifactPaths.listIterator(); iterator.hasNext();)
        {
            final Artifact artifact = (Artifact)iterator.next();
            if (classpathArtifactTypes.contains(artifact.getType()))
            {
                final File artifactFile = artifact.getFile();
                final String path =
                    StringUtils.replace(
                        ResourceUtils.normalizePath(artifactFile.toString()),
                        ResourceUtils.normalizePath(localRepository.getBasedir()),
                        repositoryVariableName);
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

                }
                if (version == null) {
                    throw new MojoExecutionException("No version set for module '" + module + "'");
                }
            }
            Artifact artifact = null;
            if (classifier != null) {
                artifact = this.artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
            } else {
                artifact = this.artifactFactory.createBuildArtifact(groupId, artifactId, version, type);
            }
            getLog().debug("Built Artifact = " + artifact);

            // now resolve this artifact
            try {
                this.artifactResolver.resolve(artifact, this.repositories, this.localRepository);
            } catch (ArtifactResolutionException e) {
                throw new MojoExecutionException("Cannot resolve artifact '" + artifactId + "'.", e);
            } catch (ArtifactNotFoundException e) {
                throw new MojoExecutionException("Artifact '" + artifactId + "' not found.", e);
            }

            // Add artifact
            artifacts.add(artifact);

        }

        FileWriter fileWriter = null;
        try {
            // Create file writer
            try {
                fileWriter = new FileWriter(this.outputFile);
            } catch (IOException e) {
                throw new MojoExecutionException("Cannot create a file on '" + this.outputFile + "'", e);
            }

            // Write the name of the files
            for (Artifact artifact : artifacts) {
                try {
                    getLog().debug("Writing " + artifact.getFile().getName());
                    fileWriter.write(artifact.getFile().getName());
                    fileWriter.write("\n");
                } catch (IOException e) {
                    throw new MojoExecutionException("Cannot write the line for Artifact '" + artifact + "' in the file '"
                            + this.outputFile + "'", e);
                }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

    }
  }

  protected Artifact resolve(String groupId, String id, String version, String type, String classifier)
      throws MojoExecutionException {
    Artifact artifact = artifactFactory.createArtifactWithClassifier(groupId, id, version, type, classifier);
    try {
      resolver.resolve(artifact, remoteRepositories, localRepository);
    } catch (ArtifactNotFoundException e) {
      throw new MojoExecutionException("artifact not found - " + e.getMessage(), e);
    } catch (ArtifactResolutionException e) {
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

      }
    }
    // resolve normally
    for (Module module : modules) {
      if (module.getArtifact() == null) {
        Artifact artifact = resolve(module.getGroupId(), module.getArtifactId(), module.getVersion(), module
            .getType(), module.getClassifier());
        module.setArtifact(artifact);
      }
    }
  }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

public class BuildMojo extends CollectMojo {

  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    super.execute();
    Artifact dojo = resolve("org.geomajas.dojo", "dojo", getDojoVersion(), "jar", null);
    DojoBuildEnvironment env = new DojoBuildEnvironment(dojo, getLog(), getArchiverManager(), getLayerName());
    env.installAndClean();
    resolveModules();
    for (Module module : getModules()) {
      env.addModule(module);
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

* @goal clean
*/
public class CleanMojo extends DojoMojo {

  public void execute() throws MojoExecutionException, MojoFailureException {
    Artifact dojo = resolve("org.geomajas.dojo", "dojo", getDojoVersion(), "jar", null);
    DojoBuildEnvironment env = new DojoBuildEnvironment(dojo, getLog(), getArchiverManager(), getLayerName());
    getLog().info("Cleaning dojo build directory");
    env.cleanAll();
  }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

        }

        if (classifier != null) {
            projectHelper.attachArtifact(project, "xar", classifier, xarFile);
        } else {
            Artifact artifact = project.getArtifact();
            if (primaryArtifact) {
                artifact.setFile(xarFile);
            } else if (artifact.getFile() == null || artifact.getFile().isDirectory()) {
                artifact.setFile(xarFile);
            } else {
                projectHelper.attachArtifact(project, "xar", xarFile);
            }
        }
    }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

        }
        final Set<String> defaultExclusionSet
                = new HashSet<String>(Arrays.asList(defaultRuntimeExcludes));
        return new ArtifactFilter() {
            public boolean include(Artifact artifact) {
                Artifact runtimeArtifact = artifacts.get(artifact.getDependencyConflictId());
                if (runtimeArtifact == null) {
                    return !defaultExclusionSet.contains(artifact.getDependencyConflictId());
                } else {
                    if (!runtimeArtifact.getVersion().equals(artifact.getVersion())) {
                        getLog().warn("Possible runtime version conflict for "
                                + artifact.getArtifactId() + ": XAR depends on "
                                + artifact.getVersion() + ", Synapse runtime provides "
                                + runtimeArtifact.getVersion());
                    }
                    return false;
                }
            }
        };
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

     * @throws MojoExecutionException
     */
    private Set<Artifact> getSynapseRuntimeArtifacts() throws MojoExecutionException {
        Log log = getLog();
        log.debug("Looking for synapse-core artifact in XAR project dependencies ...");
        Artifact synapseCore = null;
        for (Iterator<?> it = project.getDependencyArtifacts().iterator(); it.hasNext(); ) {
            Artifact artifact = (Artifact)it.next();
            if (artifact.getGroupId().equals("org.apache.synapse")
                    && artifact.getArtifactId().equals("synapse-core")) {
                synapseCore = artifact;
                break;
            }
        }
        if (synapseCore == null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.