diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-11-03 18:39:42 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-11-03 21:53:40 +0300 |
commit | 487dba687ad0891eebe61433c83c9ad5bf529b7b (patch) | |
tree | 972a405e5edb0e064bcbbb4f99ae195ff13817ce /buildSrc | |
parent | c14f3b06788df7309ba7034b030598b111540cb2 (diff) | |
download | dokka-487dba687ad0891eebe61433c83c9ad5bf529b7b.tar.gz dokka-487dba687ad0891eebe61433c83c9ad5bf529b7b.tar.bz2 dokka-487dba687ad0891eebe61433c83c9ad5bf529b7b.zip |
Fix pom generation for dokka-android-plugin
Workaround for johnrengelman/shadow#334
Diffstat (limited to 'buildSrc')
-rw-r--r-- | buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy | 39 |
1 files changed, 39 insertions, 0 deletions
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 |