How to script Gradle in order to publish shadowjar into Artifactory

后端 未结 7 492
南笙
南笙 2021-01-11 11:33

I am using shadowJar in my java project. I would like to push the outcome into artifactory.

My gradle script look like this, I am not sure how to connect the dots:

相关标签:
7条回答
  • 2021-01-11 12:12

    It's a bit late, but I'd like to show you how I got it to work. Maybe it helps someone stumbling across this question as I did:

    build.gradle.kts:

    plugins {
        java
        `maven-publish`
        id("com.github.johnrengelman.shadow") version "5.1.0"
    }
    publishing {
        publications {
            create<MavenPublication>("maven") {
                from(components["java"])
                artifact(tasks["shadowJar"])
            }
        }
        repositories {
            maven {
              /* ... */
            }
        }
    }
    

    The example above is written in Kotlin, if you prefer Groovy, you would need to write this instead:

    build.gradle:

    publishing {
      publications {
        shadow(MavenPublication) {
          from components.java
          artifact shadowJar
        }
      }
    }
    

    (found it here: https://libraries.io/github/johnrengelman/shadow)

    0 讨论(0)
提交回复
热议问题