/** * Parses exclusion parameter and build {@link Exclusion} object. * * @param exclusionString string representation of exclusion parameter * @return Exclusion object */ public static Exclusion createExclusion(String exclusionString) { String[] parts = exclusionString.split(":"); String artifactId = "*"; String classifier = "*"; String extension = "*"; int len = parts.length; if (len > 1) { artifactId = parts[1]; } if (len > 2) { classifier = parts[2]; } if (len > 3) { extension = parts[3]; } // length of parts should be greater than 0 String groupId = parts[0]; return new Exclusion(groupId, artifactId, classifier, extension); }
@Override public String toString() { return getGroupId() + ':' + getArtifactId() + ':' + getExtension() + ( getClassifier().length() > 0 ? ':' + getClassifier() : "" ); }
public static MavenDependencyExclusion fromExclusion(final Exclusion exclusion) { final MavenDependencyExclusion translated = MavenDependencies.createExclusion(exclusion.getGroupId(), exclusion.getArtifactId()); return translated; }
if (currentExclusion.getGroupId().equals(artifact.getGroupId()) && (currentExclusion.getArtifactId().equals(artifact.getArtifactId())) || (currentExclusion.getArtifactId().equals(ARTIFACT_STAR))){ getLog().debug("Filtering excluded dependency "+dependencyNode.getDependency()); return false; Exclusion dummyExclusion = new Exclusion( dependencyNode.getArtifact().getGroupId(), dependencyNode.getArtifact().getArtifactId(),
@Override public String toString() { return getGroupId() + ':' + getArtifactId() + ':' + getExtension() + ( getClassifier().length() > 0 ? ':' + getClassifier() : "" ); }
public static MavenDependencyExclusion fromExclusion(final Exclusion exclusion) { final MavenDependencyExclusion translated = MavenDependencies.createExclusion(exclusion.getGroupId(), exclusion.getArtifactId()); return translated; }
private Exclusion convert( org.apache.maven.model.Exclusion exclusion ) { return new Exclusion( exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*" ); }
public int compare( Exclusion e1, Exclusion e2 ) { if ( e1 == null ) { return ( e2 == null ) ? 0 : 1; } else if ( e2 == null ) { return -1; } int rel = e1.getArtifactId().compareTo( e2.getArtifactId() ); if ( rel == 0 ) { rel = e1.getGroupId().compareTo( e2.getGroupId() ); if ( rel == 0 ) { rel = e1.getExtension().compareTo( e2.getExtension() ); if ( rel == 0 ) { rel = e1.getClassifier().compareTo( e2.getClassifier() ); } } } return rel; }
/** * Exclusive can be specified by wildcard: * -- groupId:artifactId:*:* * -- groupId:*:*:* * <p> * And in general, to require a strict match up to the version and the classifier is not necessary * <p> * TODO: the correct fix would be to rewrite {@link Exclusion # equals (Object)}, but what about the boundary case: * If contains (id1: *: *: *, id1: id2: *: *) == true, then that's equals ?? * TODO: there must be useful code in Aether or maven on this topic * <p> * @param exclusions * @param exclusion * @return */ private boolean containsEx(Collection<Exclusion> exclusions, Exclusion exclusion){ if(exclusion != null && exclusions != null) { for(Exclusion currentExclusion: exclusions){ if (currentExclusion.getGroupId().equals(exclusion.getGroupId()) && (currentExclusion.getArtifactId().equals(exclusion.getArtifactId()) || (currentExclusion.getArtifactId().equals(ARTIFACT_STAR)))) { return true; } } } return false; }
private static Exclusion toExclusion( org.apache.maven.model.Exclusion exclusion ) { return new Exclusion( exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*" ); }
public int compare( Exclusion e1, Exclusion e2 ) { if ( e1 == null ) { return ( e2 == null ) ? 0 : 1; } else if ( e2 == null ) { return -1; } int rel = e1.getArtifactId().compareTo( e2.getArtifactId() ); if ( rel == 0 ) { rel = e1.getGroupId().compareTo( e2.getGroupId() ); if ( rel == 0 ) { rel = e1.getExtension().compareTo( e2.getExtension() ); if ( rel == 0 ) { rel = e1.getClassifier().compareTo( e2.getClassifier() ); } } } return rel; }
private static String toCapsuleExclusionsString(Collection<Exclusion> exclusions) { final StringBuilder res = new StringBuilder(); if (!exclusions.isEmpty()) { res.append("("); boolean starting = true; for (Exclusion e : exclusions) { if (!starting) res.append(","); else starting = false; res.append(e.getGroupId()); res.append(":"); if (e.getArtifactId() != null && e.getArtifactId().length() > 0) res.append(e.getArtifactId()); else res.append("*"); } res.append(")"); } return res.toString(); } }
if (TESTS_CLASSIFIER.equals(toTransform.getArtifact().getClassifier())) { return toTransform.setScope(COMPILE).setExclusions(singleton(new Exclusion("*", "*", "*", "*"))); } else { return toTransform.setScope(COMPILE);
private boolean matches( Exclusion exclusion, Artifact artifact ) { if ( !matches( exclusion.getArtifactId(), artifact.getArtifactId() ) ) { return false; } if ( !matches( exclusion.getGroupId(), artifact.getGroupId() ) ) { return false; } if ( !matches( exclusion.getExtension(), artifact.getExtension() ) ) { return false; } if ( !matches( exclusion.getClassifier(), artifact.getClassifier() ) ) { return false; } return true; }
private void setExclusions(final Collection<org.eclipse.aether.graph.Exclusion> exclusions) { List<Exclusion> result = new ArrayList<>(); for (org.eclipse.aether.graph.Exclusion exclusion : exclusions) { Exclusion temp = new Exclusion(); temp.setArtifactId(exclusion.getArtifactId()); temp.setGroupId(exclusion.getGroupId()); result.add(temp); } super.setExclusions(result); }
private Exclusion toExclusion(String s) { String[] ex = s.split(":", 2); return new Exclusion(ex[0], ex[1], null, null); }
private boolean matches( Exclusion exclusion, Artifact artifact ) { if ( !matches( exclusion.getArtifactId(), artifact.getArtifactId() ) ) { return false; } if ( !matches( exclusion.getGroupId(), artifact.getGroupId() ) ) { return false; } if ( !matches( exclusion.getExtension(), artifact.getExtension() ) ) { return false; } if ( !matches( exclusion.getClassifier(), artifact.getClassifier() ) ) { return false; } return true; }
private boolean isExcludedFromParent(Dependency dependency) { boolean result = false; if (parent != null && parent.getExclusions().size() > 0) { for (Exclusion exclusion : parent.getExclusions()) { if (exclusion != null) { if (exclusion.getArtifactId() != null && exclusion.getArtifactId().equals(dependency.getArtifact().getArtifactId())) { if (exclusion.getGroupId() != null && exclusion.getGroupId().equals(dependency.getArtifact().getGroupId())) { result = true; break; } } } } } return result; }
private Exclusion createExclusion(Map<String, Object> exclusionMap) { String group = (String) exclusionMap.get("group"); String module = (String) exclusionMap.get("module"); return new Exclusion(group, module, "*", "*"); }
private boolean isExcludedFromParent(Dependency dependency) { boolean result = false; if (parent != null && parent.getExclusions().size() > 0) { for (Exclusion exclusion : parent.getExclusions()) { if (exclusion != null) { if (exclusion.getArtifactId() != null && exclusion.getArtifactId().equals(dependency.getArtifact().getArtifactId())) { if (exclusion.getGroupId() != null && exclusion.getGroupId().equals(dependency.getArtifact().getGroupId())) { result = true; break; } } } } } return result; }