Java 类org.apache.maven.model.Exclusion 实例源码

项目:Reer    文件:DefaultPomDependenciesConverter.java   
private List<Exclusion> getExclusions(ModuleDependency dependency, Set<Configuration> configurations) {
    if (!dependency.isTransitive()) {
        return EXCLUDE_ALL;
    }
    List<Exclusion> mavenExclusions = new ArrayList<Exclusion>();
    Set<ExcludeRule> excludeRules = new HashSet<ExcludeRule>(dependency.getExcludeRules());
    for (Configuration configuration : configurations) {
        excludeRules.addAll(configuration.getExcludeRules());
    }
    for (ExcludeRule excludeRule : excludeRules) {
        Exclusion mavenExclusion = (Exclusion) excludeRuleConverter.convert(excludeRule);
        if (mavenExclusion != null) {
            mavenExclusions.add(mavenExclusion);
        }
    }
    return mavenExclusions;
}
项目:Reer    文件:MavenPomFileGenerator.java   
private void addDependency(MavenDependencyInternal dependency, String artifactId, String scope, String type, String classifier) {
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency.getGroupId());
    mavenDependency.setArtifactId(artifactId);
    mavenDependency.setVersion(mapToMavenSyntax(dependency.getVersion()));
    mavenDependency.setType(type);
    mavenDependency.setScope(scope);
    mavenDependency.setClassifier(classifier);

    for (ExcludeRule excludeRule : dependency.getExcludeRules()) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId(GUtil.elvis(excludeRule.getGroup(), "*"));
        exclusion.setArtifactId(GUtil.elvis(excludeRule.getModule(), "*"));
        mavenDependency.addExclusion(exclusion);
    }

    getModel().addDependency(mavenDependency);
}
项目:smart-testing    文件:MavenCoordinatesResolverTest.java   
@Test
public void should_create_dependency_from_gav_with_exclusions() {
    // when
    Dependency dependency =
        MavenCoordinatesResolver.createDependencyFromCoordinates(String.join(":", groupId, artifactId, version),
            true);

    // then
    assertThat(dependency)
        .hasGroupId(groupId)
        .hasArtifactId(artifactId)
        .hasVersion(version)
        .hasType("jar")
        .hasClassifier(null)
        .exclusions().hasSize(1);
    Exclusion exclusion = dependency.getExclusions().get(0);
    Assertions.assertThat(exclusion.getGroupId()).isEqualTo("*");
    Assertions.assertThat(exclusion.getArtifactId()).isEqualTo("*");
}
项目:gradle-maven-sync-plugin    文件:GradleStepdefs.java   
public void setExcludes(String exclusions) {
  if (exclusions == null) {
    return;
  }

  setExclusions(
      Stream.of(exclusions.split(","))
          .map(String::trim)
          .map(exclusion -> {
            String[] parts = exclusion.split(":");
            Exclusion result = new Exclusion();

            result.setGroupId(parts[0]);

            if (parts.length == 2) {
              result.setArtifactId(parts[1]);
            }

            return result;
          })
          .collect(Collectors.toList())
  );
}
项目:gradle-maven-share    文件:ResolvedPom.java   
protected Dependency resolve(Dependency rawDep) {
    Dependency dep = new Dependency();
    dep.setGroupId(substituteProperties(rawDep.getGroupId()));
    dep.setArtifactId(substituteProperties(rawDep.getArtifactId()));
    dep.setVersion(substituteProperties(rawDep.getVersion()));
    dep.setScope(substituteProperties(rawDep.getScope()));
    dep.setSystemPath(substituteProperties(rawDep.getSystemPath()));
    dep.setClassifier(substituteProperties(rawDep.getClassifier()));
    dep.setType(substituteProperties(rawDep.getType()));
    dep.setOptional(substituteProperties(rawDep.getOptional()));

    if (rawDep.getExclusions() != null) {
        List<Exclusion> exclusions = new ArrayList<>(rawDep.getExclusions().size());
        for (Exclusion rawEx : rawDep.getExclusions()) {
            Exclusion ex = new Exclusion();
            ex.setArtifactId(substituteProperties(rawEx.getArtifactId()));
            ex.setGroupId(substituteProperties(rawEx.getGroupId()));
            exclusions.add(ex);
        }
        dep.setExclusions(exclusions);
    }
    return dep;
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitBuildPluginDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitBuildPluginDependencyExclusion( exclusion );
            exclusion = visitor.replaceBuildPluginDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitBuildPluginManagementPluginDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitBuildPluginManagementPluginDependencyExclusion( exclusion );
            exclusion = visitor.replaceBuildPluginManagementPluginDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitDependencyExclusion( exclusion );
            exclusion = visitor.replaceDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitDependencyManagementDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitDependencyManagementDependencyExclusion( exclusion );
            exclusion = visitor.replaceDependencyManagementDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitProfileBuildPluginDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitProfileBuildPluginDependencyExclusion( exclusion );
            exclusion = visitor.replaceProfileBuildPluginDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitProfileBuildPluginManagementPluginDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitProfileBuildPluginManagementPluginDependencyExclusion( exclusion );
            exclusion = visitor.replaceProfileBuildPluginManagementPluginDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitProfileDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitProfileDependencyExclusion( exclusion );
            exclusion = visitor.replaceProfileDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitProfileDependencyManagementDependency( ModelVisitor visitor, Dependency dependency )
{
    List<Exclusion> exclusions = dependency.getExclusions();
    if ( exclusions != null )
    {
        ListIterator<Exclusion> exclusionIterator = exclusions.listIterator();
        while ( exclusionIterator.hasNext() )
        {
            Exclusion exclusion = exclusionIterator.next();
            visitor.visitProfileDependencyManagementDependencyExclusion( exclusion );
            exclusion = visitor.replaceProfileDependencyManagementDependencyExclusion( exclusion );
            if ( exclusion == null )
                exclusionIterator.remove();
            else
                exclusionIterator.set( exclusion );
        }
    }
}
项目:Pushjet-Android    文件:MavenPomFileGenerator.java   
private void addDependency(MavenDependencyInternal dependency, String artifactId, String scope, String type, String classifier) {
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency.getGroupId());
    mavenDependency.setArtifactId(artifactId);
    mavenDependency.setVersion(dependency.getVersion());
    mavenDependency.setType(type);
    mavenDependency.setScope(scope);
    mavenDependency.setClassifier(classifier);

    for (ExcludeRule excludeRule : dependency.getExcludeRules()) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId(GUtil.elvis(excludeRule.getGroup(), "*"));
        exclusion.setArtifactId(GUtil.elvis(excludeRule.getModule(), "*"));
        mavenDependency.addExclusion(exclusion);
    }

    getModel().addDependency(mavenDependency);
}
项目:sundrio    文件:ExternalBomResolver.java   
private Dependency toMavenDependency(org.eclipse.aether.graph.Dependency from) {
    org.eclipse.aether.artifact.Artifact fromArt = from.getArtifact();

    Dependency dependency = new Dependency();
    dependency.setGroupId(fromArt.getGroupId());
    dependency.setArtifactId(fromArt.getArtifactId());
    dependency.setVersion(fromArt.getVersion());
    dependency.setType(fromArt.getExtension());
    dependency.setScope(Artifact.SCOPE_COMPILE.equals(from.getScope()) ? null : from.getScope());
    dependency.setClassifier(fromArt.getClassifier());
    dependency.setOptional(dependency.isOptional());

    if (from.getExclusions() != null && from.getExclusions().size() > 0) {
        List<Exclusion> exclusions = new LinkedList<Exclusion>();
        for (org.eclipse.aether.graph.Exclusion fromEx : from.getExclusions()) {
            Exclusion ex = new Exclusion();
            ex.setGroupId(fromEx.getGroupId());
            ex.setArtifactId(fromEx.getArtifactId());
            exclusions.add(ex);
        }
        dependency.setExclusions(exclusions);
    }

    return dependency;
}
项目:os-maven-plugin    文件:DetectExtension.java   
private static void interpolate(Map<String, String> dict, Iterable<Dependency> dependencies) {
    if (dependencies == null) {
        return;
    }

    for (Dependency d: dependencies) {
        d.setGroupId(interpolate(dict, d.getGroupId()));
        d.setArtifactId(interpolate(dict, d.getArtifactId()));
        d.setVersion(interpolate(dict, d.getVersion()));
        d.setClassifier(interpolate(dict, d.getClassifier()));
        d.setSystemPath(interpolate(dict, d.getSystemPath()));
        for (Exclusion e: d.getExclusions()) {
            e.setGroupId(interpolate(dict, e.getGroupId()));
            e.setArtifactId(interpolate(dict, e.getArtifactId()));
        }
    }
}
项目:vertx-stack    文件:StackResolutionTest.java   
@Test
public void testConflictManagementUsingExclusions() {
  Dependency dependency = new Dependency("io.vertx", "vertx-core", "3.1.0");
  Exclusion exclusion1 = new Exclusion();
  exclusion1.setGroupId("com.fasterxml.jackson.core");
  exclusion1.setArtifactId("jackson-databind");
  Exclusion exclusion2 = new Exclusion();
  exclusion2.setGroupId("com.fasterxml.jackson.core");
  exclusion2.setArtifactId("jackson-core");
  dependency.addExclusion(exclusion1);
  dependency.addExclusion(exclusion2);
  Stack stack = new Stack()
      .addDependency(dependency)
      // Not the version used by vert.x
      .addDependency(new Dependency("com.fasterxml.jackson.core", "jackson-databind", "2.4.1.3"));
  StackResolution resolution = new StackResolution(stack, root, STRICT);
  resolution.resolve();
  Map<String, File> map = resolution.resolve();
  assertThat(map).containsKey("io.vertx:vertx-core:jar:3.1.0");
  assertThat(map).containsKey("com.fasterxml.jackson.core:jackson-databind:jar:2.4.1.3");
}
项目:vertx-stack    文件:StackResolutionTest.java   
@Test
public void testTheResolutionWhenATransitiveDependencyIsMissingButExcluded() {
  File local = new File("target/test-repos/incomplete");
  new LocalRepoBuilder(local).addArtifact(new LocalArtifact("org.acme", "acme", "1.0").generateMainArtifact()
      .addDependency(new LocalDependency("org.acme", "acme-missing", "1.0"))).build();

  Exclusion exclusion = new Exclusion();
  exclusion.setArtifactId("acme-missing");
  exclusion.setGroupId("org.acme");

  Dependency dependency = new Dependency("org.acme", "acme", "1.0", "txt");
  dependency.addExclusion(exclusion);

  Stack stack = new Stack()
      .addDependency(new Dependency("io.vertx", "vertx-core", "3.1.0"))
      .addDependency(dependency);
  StackResolutionOptions options = new StackResolutionOptions().setFailOnConflicts(true)
      .setLocalRepository(local.getAbsolutePath());
  StackResolution resolution = new StackResolution(stack, root, options);
  Map<String, File> map = resolution.resolve();
  assertThat(map).containsKey("io.vertx:vertx-core:jar:3.1.0");
  assertThat(map).containsKey("org.acme:acme:txt:1.0");
}
项目:vertx-stack    文件:StackResolutionTest.java   
@Test
public void testTheResolutionWhenATransitiveDependencyIsMissingButOptional() {
  File local = new File("target/test-repos/incomplete");
  new LocalRepoBuilder(local).addArtifact(new LocalArtifact("org.acme", "acme", "1.0").generateMainArtifact()
      .addDependency(new LocalDependency("org.acme", "acme-missing", "1.0").optional(true))).build();

  Exclusion exclusion = new Exclusion();
  exclusion.setArtifactId("acme-missing");
  exclusion.setGroupId("org.acme");

  Dependency dependency = new Dependency("org.acme", "acme", "1.0", "txt");
  Stack stack = new Stack()
      .addDependency(new Dependency("io.vertx", "vertx-core", "3.1.0"))
      .addDependency(dependency);
  StackResolutionOptions options = new StackResolutionOptions().setFailOnConflicts(true)
      .setLocalRepository(local.getAbsolutePath());
  StackResolution resolution = new StackResolution(stack, root, options);
  Map<String, File> map = resolution.resolve();
  assertThat(map).containsKey("io.vertx:vertx-core:jar:3.1.0");
  assertThat(map).containsKey("org.acme:acme:txt:1.0");
}
项目:vertx-deploy-tools    文件:DeployUtils.java   
public List<Exclusion> parseExclusions(String exclusions) {
    List<Exclusion> result = new ArrayList<>();
    if (StringUtils.isBlank(exclusions)) {
        return result;
    }

    Pattern.compile(";")
            .splitAsStream(exclusions)
            .forEach(s -> {
                        String[] mavenIds = Pattern.compile(":").split(s, 2);
                        if (mavenIds.length == 2) {
                            Exclusion exclusion = new Exclusion();
                            exclusion.setGroupId(mavenIds[0]);
                            exclusion.setArtifactId(mavenIds[1]);
                            result.add(exclusion);
                        }
                    }
            );
    return result;
}
项目:oceano    文件:CacheUtils.java   
private static boolean exclusionsEquals( List<Exclusion> a, List<Exclusion> b )
{
    if ( a.size() != b.size() )
    {
        return false;
    }

    Iterator<Exclusion> aI = a.iterator();
    Iterator<Exclusion> bI = b.iterator();

    while ( aI.hasNext() )
    {
        Exclusion aD = aI.next();
        Exclusion bD = bI.next();

        boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
            && eq( aD.getArtifactId(), bD.getArtifactId() );

        if ( !r )
        {
            return false;
        }
    }

    return true;
}
项目:oceano    文件:AbstractCoreMavenComponentTestCase.java   
public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion )
{
    Dependency d = new Dependency();
    d.setGroupId( groupId );
    d.setArtifactId( artifactId );
    d.setVersion( version );
    d.setScope( scope );

    if ( systemPath != null && scope.equals(  Artifact.SCOPE_SYSTEM ) )
    {
        d.setSystemPath( systemPath );
    }

    if ( exclusion != null )
    {
        d.addExclusion( exclusion );
    }

    project.getDependencies().add( d );

    return this;
}
项目:oceano    文件:AbstractCoreMavenComponentTestCase.java   
public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion )
{
    Dependency d = new Dependency();
    d.setGroupId( groupId );
    d.setArtifactId( artifactId );
    d.setVersion( version );
    d.setScope( scope );

    if ( systemPath != null && scope.equals(  Artifact.SCOPE_SYSTEM ) )
    {
        d.setSystemPath( systemPath );
    }

    if ( exclusion != null )
    {
        d.addExclusion( exclusion );
    }

    plugin.getDependencies().add( d );

    return this;
}
项目:oceano    文件:DefaultDependencyManagementInjector.java   
@Override
protected void mergeDependency_Exclusions( Dependency target, Dependency source, boolean sourceDominant,
                                           Map<Object, Object> context )
{
    List<Exclusion> tgt = target.getExclusions();
    if ( tgt.isEmpty() )
    {
        List<Exclusion> src = source.getExclusions();

        for ( Exclusion element : src )
        {
            Exclusion clone = element.clone();
            target.addExclusion( clone );
        }
    }
}
项目:jcabi-aether    文件:MavenRootArtifactTest.java   
/**
 * MavenRootArtifact can resolve a root artifact.
 * @throws Exception If there is some problem inside
 */
@Test
@SuppressWarnings("unchecked")
public void resolvesMavenRootArtifact() throws Exception {
    final DefaultArtifact artifact = new DefaultArtifact(
        // @checkstyle MultipleStringLiteralsCheck (1 line)
        "junit", "junit", "4.10", "", "jar", "",
        new DefaultArtifactHandler()
    );
    final MavenRootArtifact root = new MavenRootArtifact(
        artifact,
        new ArrayList<Exclusion>(0),
        Collections.<Artifact>singleton(artifact)
    );
    MatcherAssert.assertThat(
        root,
        Matchers.hasToString(Matchers.containsString("junit:junit:4.10"))
    );
    MatcherAssert.assertThat(
        root.children(),
        Matchers.<Artifact>hasItems(
            Matchers.hasToString("junit:junit:jar:4.10:")
        )
    );
}
项目:jcabi-aether    文件:MavenRootArtifactTest.java   
/**
 * MavenRootArtifact can gracefully resolve a root artifact.
 * @throws Exception If there is some problem inside
 */
@Test
public void gracefullyResolvesBrokenMavenRootArtifact() throws Exception {
    final MavenRootArtifact root = new MavenRootArtifact(
        new DefaultArtifact(
            "junit-broken", "junit-absent", "1.0", "", "", "",
            new DefaultArtifactHandler()
        ),
        new ArrayList<Exclusion>(0),
        new ArrayList<Artifact>(0)
    );
    MatcherAssert.assertThat(
        root,
        Matchers.hasToString(
            Matchers.containsString("junit-broken:junit-absent:1.0:0")
        )
    );
}
项目:jcabi-aether    文件:RootArtifactTest.java   
/**
 * RootArtifact can resolve a root artifact.
 * @throws Exception If there is some problem inside
 */
@Test
@SuppressWarnings("unchecked")
public void resolvesRootArtifact() throws Exception {
    final RootArtifact root = new RootArtifact(
        this.aether(),
        // @checkstyle MultipleStringLiterals (1 line)
        new DefaultArtifact("junit", "junit", "", "jar", "4.10"),
        new ArrayList<Exclusion>(0)
    );
    MatcherAssert.assertThat(
        root,
        Matchers.hasToString(Matchers.containsString("junit:junit:4.10"))
    );
    MatcherAssert.assertThat(
        root.children(),
        Matchers.<Artifact>hasItems(
            Matchers.hasToString("junit:junit:jar:4.10"),
            Matchers.hasToString("org.hamcrest:hamcrest-core:jar:1.1")
        )
    );
}
项目:Reer    文件:DefaultExcludeRuleConverter.java   
public Exclusion convert(ExcludeRule excludeRule) {
    if (isConvertable(excludeRule)) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId(determineExclusionExpression(excludeRule.getGroup()));
        exclusion.setArtifactId(determineExclusionExpression(excludeRule.getModule()));
        return exclusion;
    }
    return null;
}
项目:incubator-netbeans    文件:LocationAwareMavenXpp3Writer.java   
private void writeExclusion(Exclusion exclusion, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (exclusion.getGroupId() != null) {
        writeValue(serializer, "groupId", exclusion.getGroupId(), exclusion);
    }
    if (exclusion.getArtifactId() != null) {
        writeValue(serializer, "artifactId", exclusion.getArtifactId(), exclusion);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(exclusion, "", start, b.length());
}
项目:smart-testing    文件:MavenCoordinatesResolver.java   
static Dependency createDependencyFromCoordinates(String coordinatesString, boolean excludeTransitive) {
    final String[] coordinates = coordinatesString.split(":");
    int amountOfCoordinates = coordinates.length;
    if (amountOfCoordinates < 2) {
        throw new IllegalArgumentException(
            "Coordinates of the specified strategy [" + coordinatesString + "] doesn't have the correct format.");
    }
    final Dependency dependency = new Dependency();
    dependency.setGroupId(coordinates[0]);
    dependency.setArtifactId(coordinates[1]);
    if (amountOfCoordinates == 3) {
        dependency.setVersion(coordinates[2]);
    } else if (amountOfCoordinates >= 4) {
        dependency.setType(coordinates[2].isEmpty() ? "jar" : coordinates[2]);
        dependency.setClassifier(coordinates[3]);
    }
    if (amountOfCoordinates >= 5) {
        dependency.setVersion(coordinates[4]);
    }
    if (amountOfCoordinates == 6) {
        dependency.setScope(coordinates[5]);
    }
    if (dependency.getVersion() == null || dependency.getVersion().isEmpty()) {
        dependency.setVersion(ExtensionVersion.version().toString());
    }
    if (excludeTransitive) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId("*");
        exclusion.setArtifactId("*");
        dependency.setExclusions(Arrays.asList(exclusion));
    }
    return dependency;
}
项目:hybris-maven-plugin    文件:ExclusionWrapper.java   
public ExclusionWrapper(final String groupId, final String artifactId) {
    exclusion = new Exclusion();
    exclusion.setArtifactId(artifactId);
    exclusion.setGroupId(groupId);
    this.groupId = groupId;
    this.artifactId = artifactId;
}
项目:spring-cloud-stream-app-maven-plugin    文件:MavenModelUtils.java   
public static void addExclusionsForKafka(Model pomModel) throws IOException {

        List<Dependency> dependencies = pomModel.getDependencies();
        CopyOnWriteArrayList<Dependency> cowal = new CopyOnWriteArrayList<>(dependencies);
        for (Dependency dep : cowal) {
            if (dep.getArtifactId().startsWith("kafka_")) {
                pomModel.removeDependency(dep);
                Exclusion exclusion = new Exclusion();
                exclusion.setArtifactId("slf4j-log4j12");
                exclusion.setGroupId("org.slf4j");
                dep.addExclusion(exclusion);
                pomModel.addDependency(dep);
            }
        }
    }
项目:xmvn    文件:InstallMojo.java   
private void deployArtifact( Artifact artifact, String type, Model model )
    throws MojoExecutionException
{
    DeploymentRequest request = new DeploymentRequest();
    request.setArtifact( artifact );
    request.addProperty( "type", type );
    request.addProperty( "requiresJava", getProjectProperty( artifact, "compilerTarget" ) );

    for ( Dependency dependency : model.getDependencies() )
    {
        String scope = dependency.getScope();
        if ( scope == null || scope.equals( "compile" ) || scope.equals( "runtime" ) )
        {
            Artifact dependencyArtifact = Utils.dependencyArtifact( repoSession, dependency );

            List<Artifact> exclusions = new ArrayList<>();
            for ( Exclusion e : dependency.getExclusions() )
            {
                exclusions.add( new DefaultArtifact( e.getGroupId(), e.getArtifactId() ) );
            }

            request.addDependency( dependencyArtifact, dependency.isOptional(), exclusions );
        }
    }

    DeploymentResult result = deployer.deploy( request );
    if ( result.getException() != null )
        throw new MojoExecutionException( "Failed to deploy artifact " + artifact, result.getException() );
}
项目:Pushjet-Android    文件:DefaultPomDependenciesConverter.java   
private List<Exclusion> getExclusions(ModuleDependency dependency, Set<Configuration> configurations) {
    List<Exclusion> mavenExclusions = new ArrayList<Exclusion>();
    Set<ExcludeRule> excludeRules = new HashSet<ExcludeRule>(dependency.getExcludeRules());
    for (Configuration configuration : configurations) {
        excludeRules.addAll(configuration.getExcludeRules());
    }
    for (ExcludeRule excludeRule : excludeRules) {
        Exclusion mavenExclusion = (Exclusion) excludeRuleConverter.convert(excludeRule);
        if (mavenExclusion != null) {
            mavenExclusions.add(mavenExclusion);
        }
    }
    return mavenExclusions;
}
项目:Pushjet-Android    文件:DefaultExcludeRuleConverter.java   
public Exclusion convert(ExcludeRule excludeRule) {
    if (isConvertable(excludeRule)) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId(excludeRule.getGroup());
        exclusion.setArtifactId(excludeRule.getModule());
        return exclusion;
    }
    return null;
}
项目:Pushjet-Android    文件:DefaultPomDependenciesConverter.java   
private List<Exclusion> getExclusions(ModuleDependency dependency, Set<Configuration> configurations) {
    List<Exclusion> mavenExclusions = new ArrayList<Exclusion>();
    Set<ExcludeRule> excludeRules = new HashSet<ExcludeRule>(dependency.getExcludeRules());
    for (Configuration configuration : configurations) {
        excludeRules.addAll(configuration.getExcludeRules());
    }
    for (ExcludeRule excludeRule : excludeRules) {
        Exclusion mavenExclusion = (Exclusion) excludeRuleConverter.convert(excludeRule);
        if (mavenExclusion != null) {
            mavenExclusions.add(mavenExclusion);
        }
    }
    return mavenExclusions;
}
项目:Pushjet-Android    文件:DefaultExcludeRuleConverter.java   
public Exclusion convert(ExcludeRule excludeRule) {
    if (isConvertable(excludeRule)) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId(excludeRule.getGroup());
        exclusion.setArtifactId(excludeRule.getModule());
        return exclusion;
    }
    return null;
}
项目:vertx-stack    文件:Dependency.java   
/**
 * Creates the {@link ResolutionOptions} object for the dependency.
 *
 * @return the {@link ResolutionOptions} instructing the dependency resolution.
 */
public ResolutionOptions getResolutionOptions() {
  ResolutionOptions options = new ResolutionOptions();
  options.setWithTransitive(transitive);
  for (Exclusion exclusion : getExclusions()) {
    options.addExclusion(exclusion.getGroupId() + ":" + exclusion.getArtifactId());
  }

  return options;
}
项目:idea-maven-plugin    文件:ArtifactDependencyResolver.java   
/**
 * Convert Dependency to Artifact
 *
 * @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;
}
项目:org-treewalk-scms    文件:MavenComponentTransformation.java   
/**
 * Transform a Maven model into an SCMS Dependency
 *
 * @param dependency the maven dependency
 *
 * @return transformed dependency
 */
public static ComponentDependency transformDependency(final Dependency dependency) {
    ComponentDependency componentDependency = new ComponentDependency();
    componentDependency.setDependencyId(transformIdentifier(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()));
    componentDependency.setScope(transformScope(dependency));
    for (Exclusion exclusion:  dependency.getExclusions()) {
        componentDependency.addExclusion(transformExclusion(exclusion));
    }
    return componentDependency;
}