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.
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"`
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.
Remote repository:
Internal repository:
MavenLocal repository:
Attention: If you won't set any repository automatically the script will use MavenLocal as default repo
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"
}
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
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
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
Gradle发布工件(Publishing Artifacts) 此文章基于Gradle 4.6编写。 1. Maven Plugin(旧版) 使用Maven Plugin发布Artifcat是旧的插件,新版Gradle有新的插件Maven Publish Plugin发布Artifact,需要注意的是,如果项目使用Gradle 7.0及更新版本,maven插件已被移除,请使用Maven Publ
前言 kotlin-gradle-plugin从1.6.21升级到1.7.10引发了一系列报错。 buildscript { ext.kotlin_version = '1.7.10' ext.hilt_version = '2.41' repositories { google() mavenCentral() } depe
出现该错误的主要原因是当前仓库中没有适合的包,添加国内的maven源即可,具体方法如下: 在 Gradle Scripts->build.gradle 中添加以下国内镜像仓库,注意两个地方都要加: maven { url 'https://maven.aliyun.com/repository/google' } maven {
最直接的办法是使用vpn下载, 没有vpn就采用国内的镜像 maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.
gradle-maven-publish-plugin Gradle plugin that creates a publish task to automatically upload all of your Java, Kotlin or Androidlibraries to any Maven instance. This plugin is based on Chris Banes in
我正在使用gradle maven-publish插件。 gradlew任务 出版-出版本项目制作的所有出版物。 publishMavenWebPublicationToMavenLocal-将Maven出版物“Maven Web”发布到本地Maven存储库。 publishMavenWebPublicationToRemoteArtifactoryRepository-将Maven发布“Mave
我有一个Gradle项目,我需要转移它的所有依赖项,并与另一个Maven项目一起使用。换句话说,我如何从build.gradle生成pom.xml?
如何为定义的以下 gradle 插件编写等效的 maven 插件?
我有一个发布到maven的多平台kotlin库项目,并且一直在更新到kotlin 1.3多平台模型和kotlin-dsl 前面的groovy gradle脚本有一个modifyPom块,我在这里找到了一个示例。然而,只要我补充 无论pom数据中有什么,我都会得到相同的结果,即modifyPom groovy闭包的调用用一个非常模糊的错误中断了构建: 换句话说,修改Pom groovy闭包调用的行号
我正试图从maven迁移到gradle,但CheckStyle出现了一个奇怪的错误。 这是我得到的错误 如何让gradle使用最新版本的CheckStyle?值得注意的是,我的使用了maven checkstyle 6.10.1和6.8