Example usage for org.apache.maven.artifact.factory ArtifactFactory createDependencyArtifact

List of usage examples for org.apache.maven.artifact.factory ArtifactFactory createDependencyArtifact

Introduction

In this page you can find the example usage for org.apache.maven.artifact.factory ArtifactFactory createDependencyArtifact.

Prototype

Artifact createDependencyArtifact(String groupId, String artifactId, VersionRange versionRange, String type,
            String classifier, String scope, String inheritedScope);

Source Link

Usage

From source file:com.alibaba.citrus.maven.eclipse.base.ide.AbstractIdeSupportMojo.java

License:Apache License

private Map createManagedVersionMap(ArtifactFactory artifactFactory, String projectId,
        DependencyManagement dependencyManagement) throws MojoExecutionException {
    Map map;/*from   w  w  w.  j a  va  2s. co  m*/
    if (dependencyManagement != null && dependencyManagement.getDependencies() != null) {
        map = new HashMap();
        for (Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext();) {
            Dependency d = (Dependency) i.next();

            try {
                VersionRange versionRange = VersionRange.createFromVersionSpec(d.getVersion());
                Artifact artifact = artifactFactory.createDependencyArtifact(d.getGroupId(), d.getArtifactId(),
                        versionRange, d.getType(), d.getClassifier(), d.getScope(), d.isOptional());

                handleExclusions(artifact, d);
                map.put(d.getManagementKey(), artifact);
            } catch (InvalidVersionSpecificationException e) {
                throw new MojoExecutionException(
                        Messages.getString("AbstractIdeSupportMojo.unabletoparseversion", new Object[] { //$NON-NLS-1$
                                projectId, d.getVersion(), d.getManagementKey(), e.getMessage() }),
                        e);
            }
        }
    } else {
        map = Collections.EMPTY_MAP;
    }
    return map;
}

From source file:org.apache.tuscany.maven.plugin.eclipse.AbstractIdeSupportMojo.java

License:Apache License

private Map createManagedVersionMap(ArtifactFactory artifactFactory, String projectId,
        DependencyManagement dependencyManagement) throws MojoExecutionException {
    Map map;//from   ww  w .j  a  v  a2s .  c o m
    if (dependencyManagement != null && dependencyManagement.getDependencies() != null) {
        map = new HashMap();
        for (Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext();) {
            Dependency d = (Dependency) i.next();

            try {
                VersionRange versionRange = VersionRange.createFromVersionSpec(d.getVersion());
                Artifact artifact = artifactFactory.createDependencyArtifact(d.getGroupId(), d.getArtifactId(),
                        versionRange, d.getType(), d.getClassifier(), d.getScope(), d.isOptional());
                map.put(d.getManagementKey(), artifact);
            } catch (InvalidVersionSpecificationException e) {
                throw new MojoExecutionException(
                        Messages.getString("AbstractIdeSupportMojo.unabletoparseversion", new Object[] { //$NON-NLS-1$
                                projectId, d.getVersion(), d.getManagementKey(), e.getMessage() }),
                        e);
            }
        }
    } else {
        map = Collections.EMPTY_MAP;
    }
    return map;
}

From source file:org.hardisonbrewing.maven.core.DependencyService.java

License:Open Source License

/**
 * Create the {#link Artifact} for the specified {@link Dependency}.
 * @param dependency The {@link Dependency} to create the {@link Artifact} for.
 * @return//from  w  ww  .java2 s .  c o  m
 */
public static final Artifact createDependencyArtifact(Dependency dependency) {

    ArtifactFactory artifactFactory = getArtifactFactory();
    VersionRange versionRange = VersionRange.createFromVersion(dependency.getVersion());
    return artifactFactory.createDependencyArtifact(dependency.getGroupId(), dependency.getArtifactId(),
            versionRange, dependency.getType(), dependency.getClassifier(), dependency.getScope(),
            dependency.isOptional());
}