-
Notifications
You must be signed in to change notification settings - Fork 561
Usage of GradleMavenPush
GradleMavenPush - helper to upload Gradle Android Artifacts and Gradle Java Artifacts to Maven repositories (JCenter, Maven Central, Corporate staging/snapshot servers and local Maven repositories).
It is up to you.
This will include flag IS_JCENTER (default is "false" - Maven Central, "true" - JCenter), username and password to upload to the Maven server and so that they are kept local on your machine. The location defaults to USER_HOME/.gradle/gradle.properties
.
It may also include your signing key id, password, and secret key ring file (for signed uploads). Signing is only necessary if you're putting release builds of your project on Maven Central or JCenter.
IS_JCENTER = false
NEXUS_USERNAME = vorlonsoft
NEXUS_PASSWORD = $tr0ngP@55w0rd
signing.keyId = ABCDEF12
signing.password = P@55w0rd
signing.secretKeyRingFile = ./secring.gpg
You can modify username and password from environment variables (useful for CI). To use those environment variables on CI just export them:
export NEXUS_USERNAME = vorlonsoft
export NEXUS_PASSWORD = $tr0ngP@55w0rd
You may already have this file, in which case just edit the original. This file should contain the POM values which are common to all of your sub-project (if you have any). For instance, here's AndroidRate's:
# VERSION_NAME (default is build.gradle versionName)
VERSION_NAME = 1.2.0-SNAPSHOT
# GROUP (default is packageName)
GROUP = com.vorlonsoft
POM_DESCRIPTION = Library for Android applications, which provides rating dialog.
POM_URL = https://github.com/Vorlonsoft/AndroidRate
POM_SCM_CONNECTION = scm:git@github.com:Vorlonsoft/AndroidRate.git
POM_LICENCE_NAME = The MIT License (MIT)
POM_LICENCE_URL = https://opensource.org/licenses/MIT
POM_DEVELOPER_ID = AlexanderLS
POM_DEVELOPER_NAME = Alexander Savin
POM_DEVELOPER_EMAIL = info@vorlonsoft.com
The VERSION_NAME
value is important. If it contains the keyword SNAPSHOT
then the build will upload to the snapshot server, if not then to the release server.
If there's an environment variable called VERSION_NAME_EXTRAS
, its value will get appended at the end of VERSION_NAME
.
This can be very powerful when running from CI. For example, to have one SNAPSHOT per branch, you could
export VERSION_NAME_EXTRAS = -master-SNAPSHOT
in this case it will be uploaded to the snapshot server and indicates it's from the master branch.
The values in this file are specific to the sub-project (and override those in the root gradle.properties
). In this example, this is just the name, artifactId and packaging type:
POM_NAME = AndroidRate Library
POM_ARTIFACT_ID = androidrate
Also you can set POM_ARTIFACT_URL
, this is makes to easier to have an artifact with one artifactId but the name on JCenter something else.
Add the following at the end of each build.gradle
that you wish to upload:
apply from: 'https://raw.github.com/Vorlonsoft/GradleMavenPush/master/maven-push.gradle'
You can now build and deploy on JCenter, Maven Central or Corporate staging/snapshot servers:
$ gradle clean build uploadArchives
Build and install on local Maven (~/.m2/repository/):
$ gradle clean build install
Build and deploy on local Maven (~/.m2/repository/):
$ gradle clean build installArchives
If your modules have dependencies on each other (e.g. implementation project(':other_module')), then you should do one of the following for proper POM generation
- option A: add to top level build.gradle:
allprojects {
version = VERSION_NAME
group = GROUP
}
- option B: add to top level gradle.properties:
version = 1.2.0
group = com.vorlonsoft
There are other properties which can be set:
RELEASE_REPOSITORY_URL (defaults to Maven Central's or JCenter's staging server (depends on IS_JCENTER))
SNAPSHOT_REPOSITORY_URL (defaults to Maven Central's or JCenter's snapshot server (depends on IS_JCENTER))
POM_GENERATE_UNIQUE_SNAPSHOTS (default is "true")
POM_SCM_URL (default is POM_URL value)
POM_SCM_DEV_CONNECTION (default is POM_SCM_CONNECTION value)
POM_LICENCE_DIST (default is "repo")
POM_ORG (default is "")
POM_ORG_URL (default is "")
POM_DEVELOPER_ORG (default is POM_ORG value)
POM_DEVELOPER_ORG_URL (default is POM_ORG_URL value)
POM_DEVELOPER_ROLE (default is "Software Developer")
POM_DEVELOPER_ROLES (example "Software Architect,Software Developer", default is "")
POM_PACKAGING (default is "aar")
DOCLINT_CHECK (default is "false")
JAVADOC_ENCODING (default is "UTF-8")
JAVADOC_CHARSET (default is "UTF-8")