[GRADLE-3513] Maven plugin does not reflect dependency exclusions for group or module in generated POM Created: 27/Jul/16  Updated: 27/Jul/16  Resolved: 27/Jul/16

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 3.1-rc-1

Type: Bug
Reporter: Benjamin Muschko Assignee: Benjamin Muschko
Resolution: Fixed Votes: 0

Known Issue Of:

 Description   

Given the following build script, executing gradle uploadArchives does not properly reflect the exclusions in the generated metadata. In fact the exclusions are completely omitted.

apply plugin: 'java'
apply plugin: 'maven'

group = 'org.gradle.test'
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    compile ('org.apache.camel:camel-jackson:2.15.3') {
        exclude group: 'org.apache.camel'
    }
    compile ("commons-beanutils:commons-beanutils:1.8.3") {
        exclude module: 'commons-logging'
    }
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file://${buildDir}/repo")
        }
    }
}

This issue only occurs if the exclusion rule uses group or module. If both exclusion attribute are declare the generated metadata properly includes the exclusion.

Maven does handle this use case. I tested the following pom.xml with Maven 3.2.5.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.gradle.test</groupId>
  <artifactId>myproject</artifactId>
  <version>1.0</version>
  <dependencies>
    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>1.8.3</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <artifactId>commons-logging</artifactId>
          <groupId>*</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
</project>

Generated at Wed Jun 30 12:50:45 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.