aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main')
-rw-r--r--buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy39
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