How to script Gradle in order to publish shadowjar into Artifactory

后端 未结 7 597
南笙
南笙 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-11 11:53

    The publication section determines what you're publishing using the maven-publish plugin.

    In your current config, from components.java is going to publish the default jar artifact of your project and artifact sourceJar publishes the sourceJar. In order to publish a different jar, you need to modify (or add a new) publication.

    shadowJar {
      baseName = 'myproject-shadow'
      classifier = ''
    }
    
    publishing {
      publications {
        shadow(MavenPublication) {
          from components.shadow
          artifactId = 'myproject-shadow'
        }
      }
    }
    

    The version used in the name of the jar comes from project.version.

提交回复
热议问题