diff options
-rw-r--r-- | buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy | 39 | ||||
-rw-r--r-- | runners/android-gradle-plugin/build.gradle | 7 |
2 files changed, 44 insertions, 2 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 diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle index 8e97d9d9..193b8eee 100644 --- a/runners/android-gradle-plugin/build.gradle +++ b/runners/android-gradle-plugin/build.gradle @@ -1,3 +1,5 @@ +import org.jetbrains.CorrectShadowPublishing + apply plugin: 'java' apply plugin: 'kotlin' @@ -47,13 +49,14 @@ apply plugin: 'maven-publish' publishing { publications { - dokkaAndroidGradlePlugin(MavenPublication) { publication -> + dokkaAndroidGradlePlugin(MavenPublication) { MavenPublication publication -> artifactId = 'dokka-android-gradle-plugin' artifact sourceJar { classifier "sources" } - project.shadow.component(publication) + + CorrectShadowPublishing.configure(publication, project) } } } |