如何脚本摇篮才能发布shadowjar到Artifactory的 [英] How to script Gradle in order to publish shadowjar into Artifactory

查看:357
本文介绍了如何脚本摇篮才能发布shadowjar到Artifactory的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Java项目中使用shadowJar。
我想推动的结果为artifactory的。

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

我的剧本的gradle这个样子,我不知道怎么连点:

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

shadowJar {
    baseName = 'com.mycompany.myapp'
    manifest {
        attributes 'Main-Class': 'myapp.starter'
    }
}


  ]
    apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'maven'
    apply plugin: 'com.github.johnrengelman.shadow'


    // rep for the project
    repositories {
        mavenCentral()
        maven {
            url 'http://repo.company:8081/artifactory/libs-release'
            credentials {
                username = "${repo_user}"
                password = "${repo_password}"
            }
        }
        maven {
            url 'http://repo.company:8081/artifactory/libs-snapshot'
            credentials {
                username = "${repo_user}"
                password = "${repo_password}"
            }
        }

}


publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java

            artifact sourceJar {
                classifier "sources"
            }
        }
    }
}

我如何code gradle这个拿shadowjar文件?

How do I code gradle to take the shadowjar file?

谢谢,
射线。

thanks, ray.

推荐答案

发表部分确定你使用的 Maven的发布发布什么插件。

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

在当前的配置,从components.java 将要发布项目和工件的默认罐子神器 sourceJar 出版sourceJar。为了发布一个不同的罐子,你需要修改(或添加新)发布。

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'
    }
  }
}

在罐子的名称中使用的版本来自project.version。

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

这篇关于如何脚本摇篮才能发布shadowjar到Artifactory的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆