Blog moved to Https://blog.wangjiegulu.com
RSS Subscription: Https://blog.wangjiegulu.com/feed.xml
Rapidmavenpushplugin
The Gradle plugin for uploading your library to multiple Maven repositories.
Github:https://github.com/wangjiegulu/rapidmavenpushplugin
1. How to use 1.1 to add dependencies
Add dependencies to the files in your project's root directory build.gradle
RapidMavenPushPlugin
:
Check the latest version
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath('com.github.wangjiegulu:rapidmavenpush:x.x.x') { exclude group: 'com.android.tools.build', module: 'gradle' } }}
1.2 Creating Properties Files
Now that you have 3 maven repositories ( maven type
s), you will need to create 3 Maven properties archive files and a generic archive properties file (the properties file name and location can be arbitrary):
- maven_local.properties: Upload archives to the local MAVEN repository, which is on your PC by default
~/.m2/repository
.
- maven_company.properties: Upload archives to your company's MAVEN repository and deploy it on your company's servers.
- maven_central.properties: Upload archives to Maven Central Library.
- common.properties: The general properties of the above 3 maven repositories.
Note: When project.afterEvaluate
you do, all properties are automatically injected into the project.ext
, so after that you can use them in a way like this $POM_ARCHIVE_ID
.
1.2.1 Maven_common.properties
# project infoPOM_ARCHIVE_GROUP=com.github.wangjiegulu#POM_ARCHIVE_VERSION_NAME=0.0.1-SNAPSHOT (command typed)# aar or jarPOM_PACKAGING=aarPOM_DESC=test-mavenpush-pluginPOM_URL=https://github.com/wangjieguluPOM_SCM_URL=scm:[email protected]:wangjieguluPOM_SCM_CONNECTION=scm:[email protected]:wangjiegulu[email protected]:wangjieguluPOM_LICENCE_NAME=The Apache Software License, Version 2.0POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txtPOM_LICENCE_DIST=wangjiePOM_DEVELOPER_ID=wangjiePOM_DEVELOPER_NAME=Wang Jie[email protected]
1.2.2 Maven_local.properties
# maven repositoryPOM_REPOSITORY_URL=/Users/wangjie/.m2/repositoryPOM_REPOSITORY_URL_SNAPSHOT=/Users/wangjie/.m2/repositoryPOM_SIGN=false# project infoPOM_ARCHIVE_ID=mavenpush-plugin-depmodule-local
1.2.3 Maven_central.properties
POM_OSSRH_USERNAME=usernamePOM_OSSRH_PASSWORD=password# maven repositoryPOM_REPOSITORY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/POM_REPOSITORY_URL_SNAPSHOT=https://oss.sonatype.org/content/repositories/snapshots/POM_SIGN=true# Already configure in ~/.gradle/gradle.properties#signing.keyId=#signing.password=#signing.secretKeyRingFile=# project infoPOM_ARCHIVE_ID=mavenpush-plugin-depmodule
1.3 Application Plugin & Properties
In your library build.gradle
file, you need to apply the Rapidmavenpushplugin plugin in the following ways:
Apply plugin: ' Com.github.wangjiegulu.plg.rapidmavenpush ' rapidmavenpush {//If true, the properties injected will be printed at compile time PRINTP Roperties = TRUE//If True, the compilation is terminated when an error occurs in the injection properties Abortonerror = false//whether Rapid Maven Push Plugin di is disabled Sable = false//If ' pom_maven_type ' is not set, the default MAVEN TYPE is used. Defaultmaventype = ' Local ' mavens {maven {maventype = ' local ' propertyfiles = [ File ("Mavenupload/maven_common.properties"), File ("Mavenupload/maven_local.properties") ]//Property Inject Mode:if The properties are already set, replace it or skip//property Note In mode: If the properties have already been set, then replace or skip Propertyinjectmode = ' Replace '} maven {maventype = ' Company ' propertyfiles = [File ("Mavenupload/maven_common.properties"), File ("Mavenupload/maven_company.properties")] PropertyiNjectmode = ' Replace '} maven {maventype = ' central ' propertyfiles = [ File ("Mavenupload/maven_common.properties"), File ("Mavenupload/maven_central.properties") ] Propertyinjectmode = ' Replace '}}
1.4 Upload Archives
After compiling, rapid Maven Push plugin automatically creates a rapidUploadArchives
task named.
Execute this task!
Upload archives to the local repository:
./gradlew clean :depmodule:rapidUploadArchives -PPOM_MAVEN_TYPE=local
Upload Archives to Central Library:
./gradlew clean :depmodule:rapidUploadArchives -PPOM_MAVEN_TYPE=central
Note: parameters are necessary if you do not set them in build.gradle
ext.POM_MAVEN_TYPE=xxx
the way you use them POM_MAVEN_TYPE
.
1.5 Supported Parameters & properties
// maven type, 只能通过在 `build.gradle` 设置 `ext.POM_MAVEN_TYPE=xxx` 或者在命令行中设置 `-PPOM_MAVEN_TYPE=xxx` 或者在 `gradle.properties` 中设置 `PPOM_MAVEN_TYPE=xxx`POM_MAVEN_TYPE// maven repository parametersPOM_REPOSITORY_URLPOM_REPOSITORY_URL_SNAPSHOTPOM_OSSRH_USERNAMEPOM_OSSRH_PASSWORD// sign parametersPOM_SIGNsigning.keyIdsigning.passwordsigning.secretKeyRingFile// archive parametersPOM_ARCHIVE_GROUPPOM_ARCHIVE_IDPOM_ARCHIVE_VERSION_NAMEPOM_PACKAGINGPOM_DESCPOM_URLPOM_SCM_URLPOM_SCM_CONNECTIONPOM_SCM_DEV_CONNECTIONPOM_LICENCE_NAMEPOM_LICENCE_URLPOM_LICENCE_DISTPOM_DEVELOPER_IDPOM_DEVELOPER_NAMEPOM_DEVELOPER_EMAIL
License
Copyright 2018 Wang JieLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
[Android] Gradle plugin uploaded to multiple maven repositories Rapidmavenpushplugin