List of usage examples for org.apache.maven.artifact.factory ArtifactFactory createDependencyArtifact
Artifact createDependencyArtifact(String groupId, String artifactId, VersionRange versionRange, String type,
String classifier, String scope, String inheritedScope, boolean optional);
From source file:com.github.zhve.ideaplugin.ArtifactDependencyResolver.java
License:Apache License
/** * Convert Dependency to Artifact//from www. ja v a2 s.c o m * * @param artifactFactory standard Maven's factory to create artifacts * @param dependency dependency * @return artifact * @throws InvalidVersionSpecificationException if VersionRange is invalid */ private Artifact toDependencyArtifact(ArtifactFactory artifactFactory, Dependency dependency) throws InvalidVersionSpecificationException { // instantiate Artifact dependencyArtifact = artifactFactory.createDependencyArtifact(dependency.getGroupId(), dependency.getArtifactId(), VersionRange.createFromVersionSpec(dependency.getVersion()), dependency.getType(), dependency.getClassifier(), dependency.getScope() == null ? Artifact.SCOPE_COMPILE : dependency.getScope(), null, dependency.isOptional()); // apply exclusions is needed if (!dependency.getExclusions().isEmpty()) { List<String> exclusions = new ArrayList<String>(); for (Exclusion exclusion : dependency.getExclusions()) exclusions.add(exclusion.getGroupId() + ":" + exclusion.getArtifactId()); dependencyArtifact.setDependencyFilter(new ExcludesArtifactFilter(exclusions)); } // additional if (Artifact.SCOPE_SYSTEM.equalsIgnoreCase(dependency.getScope())) dependencyArtifact.setFile(new File(dependency.getSystemPath())); return dependencyArtifact; }
From source file:com.github.zhve.ideaplugin.ArtifactDependencyResolver.java
License:Apache License
private static Artifact toDependencyArtifact(ArtifactFactory artifactFactory, Artifact dependency, String inheritedScope) {/* w ww. j a va2 s . c o m*/ Artifact dependencyArtifact = artifactFactory.createDependencyArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersionRange(), dependency.getType(), dependency.getClassifier(), dependency.getScope(), inheritedScope, dependency.isOptional()); if (dependencyArtifact != null) dependencyArtifact.setDependencyFilter(dependency.getDependencyFilter()); return dependencyArtifact; }