• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

sky-uk/gradle-maven-plugin: Gradle 5.x Maven Publish Plugin to deploy artifacts

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

sky-uk/gradle-maven-plugin

开源软件地址(OpenSource Url):

https://github.com/sky-uk/gradle-maven-plugin

开源编程语言(OpenSource Language):


开源软件介绍(OpenSource Introduction):

Gradle Maven Plugin

This is a small "plugin" to simplify the use of maven-publish Gradle plugin. You can use this plugin for Java Library and Android Library.

Index

Usage

In order to use GradleMavenizer you have to add the line

apply from: 'https://raw.githubusercontent.com/sky-uk/gradle-maven-plugin/master/gradle-mavenizer.gradle'

at the very bottom of the build.gradle file. Alternatively, to use a specific release version, add this property to the project (see Releases at the top of the Github page for released versions):

mavPluginVersion = '1.2.0'

and add this line to the very bottom of the build.gradle file:

apply from: "https://raw.githubusercontent.com/sky-uk/gradle-maven-plugin/${project.mavPluginVersion}/gradle-mavenizer.gradle"`

Customization

GradleMavenizer is highly customizable.

You can customize it adding some properties to the root project build.gradle or to the module build.gradle file.

Attention: If you add the same property to the root project file and to the module file, in order of priority, the module file property will override the root project property.

1. Generic Project Info (included in POM)

  • mavProjectName -> String property -> Identify the project name (can be different from the artifactId)
  • mavLibraryDescription -> String property -> A simple description for the library
  • mavDevelopers -> Map property -> A map with the ids and the developer name of the library
  • mavLibraryLicenses -> Map property -> A map with the name and the urls of the library licenses
  • mavSiteUrl -> String property -> Identify the url of the project website
  • mavGitUrl -> String property ->Identify the url of the project github page

2. Repositories

  • Remote repository:

    • mavPublishToRemoteRepo -> Boolean property -> Allow the script to load your library to a remote repo
    • mavRemoteRepoUser -> String property -> Username to grant access to the remote repo
    • mavRemoteRepoPassword -> String property -> Password to grant access to the remote repo
    • mavRepoRemoteUrl -> String property -> Identify the url of the remote repo
  • Internal repository:

    • mavPublishToInternalRepo -> Boolean property -> Allow the script to load your library to an internal repo
    • mavRepoInternalUrl -> String property -> Identify the url of the internal repo
  • MavenLocal repository:

    • mavPublishToMavenLocal -> Boolean property -> Allow the script to load your library to MavenLocal folder

Attention: If you won't set any repository automatically the script will use MavenLocal as default repo

Example of per-module build.gradle costumization

project.ext {
    mavDevelopers = ["Fe":"Federico"]
    mavSiteUrl = "https://github.com/sky-uk/gradle-maven-plugin"
    mavGitUrl = mavSiteUrl + '.git'
    mavProjectName = 'GradleMavenizer'
    mavPublishToInternalRepo = true
    mavRepoInternalUrl = "path/to/internal/repo"
    mavLibraryLicenses = ["Apache-2.0":'http://www.apache.org/licenses/LICENSE-2.0.txt']
    mavLibraryDescription = "A simple description of the project"
}

Library Publish

To finally publish you library you can use the command ./gradlew publish directly from your project root folder.

You can also pass some properties directly from command line using the command -P (every property must have -P before), for example: ./gradlew publish -PmavPublishToMavenLocal=true

Maven Central Publish

Follow this guide if you need to get a Sonatype account and generate a GPG key. Those matters are out of scope here.

In your project root, add local.properties (make sure to ignore it in your repo and not commit it) with the following content:

signing.keyId=ABCDEFGH
signing.password=yourPassword
signing.secretKeyRingFile=/path/to/ABCDEFGH.gpg

mavRepoRemoteUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2/
mavRemoteRepoUser=yourSonatypeUsername
mavRemoteRepoPassword=yourSonatypePassword

Then to publish a staging repository on Maven Central execute:

./gradlew publish -PmavSigning=true -PmavPublishToRemoteRepo=true --max-workers 1

The --max-workers 1 setting is important to ensure the publication does not get split in multiple publications when using gradle parallel builds, resulting in many stagng repositories on sonatype. It's always advised to specify it.

After you executed the command, you can browse and review what's been uploaded by visiting https://oss.sonatype.org/#stagingRepositories

Generate POM file

If you want to generate the POM file without publish your library you can use the command ./gradlew generatePomFileForMavenPublishPublication directly from your project root folder.

To generate the POM file only for one module of your library you can use the command ./gradlew your-module-name:generatePomFileForMavenPublishPublication where you have to replace your-module-name with the name you chose for your module.

Note: POM file will be saved in build/publications/mavenPublish/ as pom-default.xml




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
SrikanthPB/mavenwebhook发布时间:2022-08-16
下一篇:
jcgay/maven-color: A colorized Maven console发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap