From 487dba687ad0891eebe61433c83c9ad5bf529b7b Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 3 Nov 2017 18:39:42 +0300 Subject: Fix pom generation for dokka-android-plugin Workaround for johnrengelman/shadow#334 --- .../org/jetbrains/CorrectShadowPublishing.groovy | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy (limited to 'buildSrc') diff --git a/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy b/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy new file mode 100644 index 00000000..3e1d2106 --- /dev/null +++ b/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy @@ -0,0 +1,39 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.api.artifacts.ModuleVersionIdentifier +import org.gradle.api.artifacts.ProjectDependency +import org.gradle.api.artifacts.SelfResolvingDependency +import org.gradle.api.publish.internal.ProjectDependencyPublicationResolver +import org.gradle.api.publish.maven.MavenPom +import org.gradle.api.publish.maven.MavenPublication + +static void configure(MavenPublication publication, Project project) { + publication.artifact(project.tasks.shadowJar) + + publication.pom { MavenPom pom -> + pom.withXml { xml -> + def dependenciesNode = xml.asNode().appendNode('dependencies') + + project.configurations.shadow.allDependencies.each { + //if (! (it instanceof SelfResolvingDependency)) { + if (it instanceof ProjectDependency) { + def projectDependencyResolver = project.gradle.services.get(ProjectDependencyPublicationResolver) + ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(it) + addDependency(dependenciesNode, identifier) + } else if (!(it instanceof SelfResolvingDependency)) { + addDependency(dependenciesNode, it) + } + + } + } + } +} + +private static void addDependency(Node dependenciesNode, dep) { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', dep.group) + dependencyNode.appendNode('artifactId', dep.name) + dependencyNode.appendNode('version', dep.version) + dependencyNode.appendNode('scope', 'runtime') +} \ No newline at end of file -- cgit