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

As of 3.2.18/3.3.6/3.4.0, optional dependencies won't be published in pom.xml anymore #2262

Closed
simonbasle opened this issue Jul 9, 2020 · 0 comments
Assignees
Labels
type/chores A task not related to code (build, formatting, process, ...)

Comments

@simonbasle
Copy link
Member

Motivation

While originally a side effect of removing problematic dependency plugin (see #2151), we discussed this with the team and took some insight from the Spring Framework and Spring Boot teams and decided that we'd stop publishing optional dependencies to the pom.

For now we won't advertise a feature in Gradle either. Note the only candidate would be metrics (with the optional dependency to micrometer).

For more context, see spring-projects/spring-framework#23234

Desired solution

The optional entries are effectively already out of the pom. The MavenPublication.withXml() is currently no-op, and should be replaced with a comment pointing to this issue for context.

Considered alternatives

If we were to re-introduce optional-marked dependencies in the generated Maven pom, the following block of code should be used in MavenPublication.withXml() in the Gradle build:

withXml {
	project.configurations.optional.allDependencies.each { optDep ->
		Node d = asNode().dependencies[0].appendNode('dependency')
		d.appendNode('groupId', optDep.group)
		d.appendNode('artifactId', optDep.name)
		d.appendNode('version', optDep.version)
		d.appendNode('scope', 'compile')
		d.appendNode('optional', true)
		println "$optDep.group:$optDep.name:$optDep.version has been marked as optional in generated pom"
	}

	//groovy magic incantation to sort dependencies alphabetically (optional/scope/group/name..)
	def sorted = asNode().dependencies[0].children().collect().sort { it.optional.text() + it.scope.text() + it.groupId.text() + it.artifactId.text() }
	asNode().dependencies[0].children().with { deps ->
		deps.clear()
		sorted.each { deps.add(it) }
	}
}
@simonbasle simonbasle added the type/chores A task not related to code (build, formatting, process, ...) label Jul 9, 2020
@simonbasle simonbasle added this to the 3.2.19.RELEASE milestone Jul 9, 2020
@simonbasle simonbasle self-assigned this Jul 9, 2020
simonbasle added a commit that referenced this issue Jul 9, 2020
The `withXml` block had become no-op, because OptionalDependenciesPlugin
doesn't generate `<dependency>` blocks for these.

It is replaced with a comment that makes it clearer that these optional
dependencies are not included in the pom anymore, on purpose.
simonbasle added a commit that referenced this issue Jul 15, 2020
simonbasle added a commit that referenced this issue Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/chores A task not related to code (build, formatting, process, ...)
Projects
None yet
Development

No branches or pull requests

1 participant