Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude api and implementation configurations from pom dependencies #615

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ class ShadowJavaPlugin implements Plugin<Project> {
}
upload.configuration = project.configurations.shadow
MavenPom pom = upload.repositories.mavenDeployer.pom
if (project.configurations.findByName("api")) {
pom.scopeMappings.mappings.remove(project.configurations.api)
}
pom.scopeMappings.mappings.remove(project.configurations.compile)
pom.scopeMappings.mappings.remove(project.configurations.implementation)
pom.scopeMappings.mappings.remove(project.configurations.runtime)
pom.scopeMappings.addMapping(MavenPlugin.RUNTIME_PRIORITY, project.configurations.shadow, Conf2ScopeMappingContainer.RUNTIME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,53 @@ class PublishingSpec extends PluginSpecification {
assert dependency.version.text() == '1.0'
}

def "exclude api and implementation dependencies when publishing shadow jar with maven plugin"() {
given:
repo.module('shadow', 'a', '1.0')
.insertFile('a.properties', 'a')
.insertFile('a2.properties', 'a2')
.publish()
repo.module('shadow', 'b', '1.0')
.insertFile('b.properties', 'b')
.publish()

settingsFile << "rootProject.name = 'maven'"
buildFile << """
apply plugin: 'java-library'
apply plugin: 'maven'

dependencies {
api 'shadow:a:1.0'
implementation 'shadow:b:1.0'
}

uploadShadow {
repositories {
mavenDeployer {
repository(url: "${publishingRepo.uri}")
}
}
}
""".stripIndent()

when:
runner.withArguments('uploadShadow').build()

then: 'Check that shadow artifact exists'
File publishedFile = publishingRepo.rootDir.file('shadow/maven/1.0/maven-1.0-all.jar').canonicalFile
assert publishedFile.exists()

and: 'Check contents of shadow artifact'
contains(publishedFile, ['a.properties', 'a2.properties'])

and: 'Check that shadow artifact pom exists and contents'
File pom = publishingRepo.rootDir.file('shadow/maven/1.0/maven-1.0.pom').canonicalFile
assert pom.exists()

def contents = new XmlSlurper().parse(pom)
assert contents.dependencies.size() == 0
}

@Issue('SHADOW-347')
def "maven install with application plugin"() {
given:
Expand Down