Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19859

Is it possible to substitute a project dependency with its outgoing artifacts?

$
0
0

To answer myself, it seems that the following hack can do the trick:

// consumer/build.gradle

publishing {
	publications {
		maven(MavenPublication) {
			pom.withXml {
				def dependenciesNode = asNode().appendNode('dependencies')

				configurations.classpath.resolvedConfiguration.resolvedArtifacts.each {
					def id = it.moduleVersion.id
					def dependencyNode = dependenciesNode.appendNode('dependency')
					dependencyNode.appendNode('groupId', id.group)
					dependencyNode.appendNode('artifactId', id.name)
					dependencyNode.appendNode('version', id.version)
					dependencyNode.appendNode('scope', 'runtime')
					if (it.classifier) {
						dependencyNode.appendNode('classifier', it.classifier)
					}
					if (it.type) {
						dependencyNode.appendNode('type', it.type)
					}
				}
			}
		}
	}
}

So I’ll change my question to, is there any way to achieve the same result with a DSL option somewhere in the variant selection/transformation API ?

Thanks a lot


Viewing all articles
Browse latest Browse all 19859

Trending Articles