use of org.apache.maven.model.Exclusion in project gradle by gradle.
the class DefaultPomDependenciesConverter method initExcludeAll.
private static List<Exclusion> initExcludeAll() {
Exclusion excludeAll = new Exclusion();
excludeAll.setGroupId("*");
excludeAll.setArtifactId("*");
return Collections.singletonList(excludeAll);
}
use of org.apache.maven.model.Exclusion in project maven-plugins by apache.
the class AnalyzeDepMgt method checkDependencyManagement.
/**
* Does the work of checking the DependencyManagement Section.
*
* @return true if errors are found.
* @throws MojoExecutionException
*/
private boolean checkDependencyManagement() throws MojoExecutionException {
boolean foundError = false;
getLog().info("Found Resolved Dependency/DependencyManagement mismatches:");
List<Dependency> depMgtDependencies = null;
DependencyManagement depMgt = project.getDependencyManagement();
if (depMgt != null) {
depMgtDependencies = depMgt.getDependencies();
}
if (depMgtDependencies != null && !depMgtDependencies.isEmpty()) {
// put all the dependencies from depMgt into a map for quick lookup
Map<String, Dependency> depMgtMap = new HashMap<String, Dependency>();
Map<String, Exclusion> exclusions = new HashMap<String, Exclusion>();
for (Dependency depMgtDependency : depMgtDependencies) {
depMgtMap.put(depMgtDependency.getManagementKey(), depMgtDependency);
// now put all the exclusions into a map for quick lookup
exclusions.putAll(addExclusions(depMgtDependency.getExclusions()));
}
// get dependencies for the project (including transitive)
Set<Artifact> allDependencyArtifacts = new LinkedHashSet<Artifact>(project.getArtifacts());
// depMgt. That's ok.
if (this.ignoreDirect) {
getLog().info("\tIgnoring Direct Dependencies.");
Set<Artifact> directDependencies = project.getDependencyArtifacts();
allDependencyArtifacts.removeAll(directDependencies);
}
// log exclusion errors
List<Artifact> exclusionErrors = getExclusionErrors(exclusions, allDependencyArtifacts);
for (Artifact exclusion : exclusionErrors) {
getLog().info(StringUtils.stripEnd(getArtifactManagementKey(exclusion), ":") + " was excluded in DepMgt, but version " + exclusion.getVersion() + " has been found in the dependency tree.");
foundError = true;
}
// find and log version mismatches
Map<Artifact, Dependency> mismatch = getMismatch(depMgtMap, allDependencyArtifacts);
for (Map.Entry<Artifact, Dependency> entry : mismatch.entrySet()) {
logMismatch(entry.getKey(), entry.getValue());
foundError = true;
}
if (!foundError) {
getLog().info("\tNone");
}
} else {
getLog().info("\tNothing in DepMgt.");
}
return foundError;
}
use of org.apache.maven.model.Exclusion in project maven-plugins by apache.
the class TestAnalyzeDepMgt method setUp.
protected void setUp() throws Exception {
mojo = new AnalyzeDepMgt();
MavenProject project = new DependencyProjectStub();
stubFactory = new DependencyArtifactStubFactory(new File(""), false);
Set<Artifact> allArtifacts = stubFactory.getMixedArtifacts();
Set<Artifact> directArtifacts = stubFactory.getClassifiedArtifacts();
exclusionArtifact = stubFactory.getReleaseArtifact();
directArtifacts.add(exclusionArtifact);
ex = new Exclusion();
ex.setArtifactId(exclusionArtifact.getArtifactId());
ex.setGroupId(exclusionArtifact.getGroupId());
exclusion = new Dependency();
exclusion.setArtifactId(exclusionArtifact.getArtifactId());
exclusion.setGroupId(exclusionArtifact.getGroupId());
exclusion.setType(exclusionArtifact.getType());
exclusion.setClassifier("");
exclusion.setVersion("3.0");
exclusion.addExclusion(ex);
List<Dependency> list = new ArrayList<Dependency>();
list.add(exclusion);
depMgt = new DependencyManagement();
depMgt.setDependencies(list);
project.setArtifacts(allArtifacts);
project.setDependencyArtifacts(directArtifacts);
mojo.setProject(project);
}
use of org.apache.maven.model.Exclusion in project maven-plugins by apache.
the class ShadeMojo method updateExcludesInDeps.
public boolean updateExcludesInDeps(MavenProject project, List<Dependency> dependencies, List<Dependency> transitiveDeps) throws DependencyGraphBuilderException {
DependencyNode node = dependencyGraphBuilder.buildDependencyGraph(project, null);
boolean modified = false;
for (DependencyNode n2 : node.getChildren()) {
for (DependencyNode n3 : n2.getChildren()) {
// check if it really isn't in the list of original dependencies. Maven
// prior to 2.0.8 may grab versions from transients instead of
// from the direct deps in which case they would be marked included
// instead of OMITTED_FOR_DUPLICATE
// also, if not promoting the transitives, level 2's would be included
boolean found = false;
for (Dependency dep : transitiveDeps) {
if (dep.getArtifactId().equals(n3.getArtifact().getArtifactId()) && dep.getGroupId().equals(n3.getArtifact().getGroupId()) && (dep.getType() == null || dep.getType().equals(n3.getArtifact().getType()))) {
found = true;
break;
}
}
if (!found) {
for (Dependency dep : dependencies) {
if (dep.getArtifactId().equals(n2.getArtifact().getArtifactId()) && dep.getGroupId().equals(n2.getArtifact().getGroupId()) && (dep.getType() == null || dep.getType().equals(n2.getArtifact().getType()))) {
Exclusion exclusion = new Exclusion();
exclusion.setArtifactId(n3.getArtifact().getArtifactId());
exclusion.setGroupId(n3.getArtifact().getGroupId());
dep.addExclusion(exclusion);
modified = true;
break;
}
}
}
}
}
return modified;
}
use of org.apache.maven.model.Exclusion in project maven-plugins by apache.
the class MavenJDOMWriter method iterateExclusion.
// -- void iterateDeveloper(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
* Method iterateExclusion
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iterateExclusion(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
boolean shouldExist = list != null && list.size() > 0;
Element element = updateElement(counter, parent, parentTag, shouldExist);
if (shouldExist) {
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
if (!elIt.hasNext()) {
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext()) {
Exclusion value = (Exclusion) it.next();
Element el;
if (elIt != null && elIt.hasNext()) {
el = (Element) elIt.next();
if (!elIt.hasNext()) {
elIt = null;
}
} else {
el = factory.element(childTag, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
updateExclusion(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
Aggregations