Giter VIP home page Giter VIP logo

michaelzx / gradle-maven-publication Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaedea/gradle-maven-publication

0.0 2.0 0.0 399 KB

Gradle maven artifacts publishing walkaround with 'maven', 'maven-publish', 'android-maven' gradle plugins. The project contains both of scripts and custom gradle plugin which are designed to make the publishing jobs much simpler and correct. Of course, both java & android project are supported!

Home Page: https://docs.gradle.org/current/userguide/publishing_overview.html

License: Apache License 2.0

Kotlin 1.93% Groovy 94.64% Java 3.43%

gradle-maven-publication's Introduction

Gradle Maven Publication

Download Build Status

Banner

Gradle scripts/plugin that helps to publish jar/aar artifacts with gradle maven or maven-publish plugin.

This repository contains two components: scripts and plugin.

The scripts work just like chrisbanes/gradle-mvn-push but suport with both maven and maven-publish, as well as more customization with pom.xml. The plugin is going to be a custom gradle plugin which makes the workflow much simpler.

Of course, the scripts/plugin are designed to work both with java and android project.

Project Structure

Demo projects Description
app Demo app module
lib-android Demo android library module
lib-android-sub Demo android library module 2
lib-java Demo java library module
lib-java-sub Demo java library module 2
Script Description
gradle/maven.gradle Workaround script with gradle plugin 'maven'
gradle/maven-dcendents.gradle Workaround script with 3rd-party gradle plugin 'android-maven'
gradle/maven-publish.gradle Workaround script with gradle plugin 'maven-publish'
Plugin Description
gradle-plugin/publication Custom gradle plugin that helps to publish jar/aar artifacts (WIP)

Getting Started

Script

  1. Config the properties required by the script.
  2. Apply the script file on demand in 'build.gradle'.
  3. Run the script tasks to publish artifacts to local/remote repository.

Config the project properties (gradle.properties) like:

GROUP=com.kaedea
VERSION_NAME=0.1.0-SNAPSHOT

RELEASE_REPOSITORY_URL=
SNAPSHOT_REPOSITORY_URL=
NEXUS_USERNAME=
NEXUS_PASSWORD=

Apply the script in your project's build.gradle:

// We have 2 ways to apply the script:
// 1. apply from remote url
// 2. apply from scirpt file from 'project/gradle/..'

// For leagcy 'maven' plugin:
apply from: 'http://kaedea.github.com/gradle-maven-publication/gradle/maven.gradle'

// For dcendents's 'android-maven' plugin:
apply from: 'http://kaedea.github.com/gradle-maven-publication/gradle/maven-dcendents.gradle'

// For new 'maven-publish' plugin:
apply from: 'http://kaedea.github.com/gradle-maven-publication/gradle/maven-publish.gradle'

At last, run the following tasks to publish:

# For leagcy 'maven' or dcendents's 'android-maven' plugin:
gradle :uploadArchives

# For new 'maven-publish' plugin:
gradle :generatePomFileForArchivesPublication
gradle :publishToMavenLocal
gradle :publish

Upload to Bintray

Apply the bintray script to upload the artifacts to Bintray/JCenter (additional).

Config the project properties like:

BINTRAY_USERNAME=
BINTRAY_API_KEY=
BINTRAY_REPO=maven

Apply the script in your project's build.gradle as Script above, then apply the bintray script:

apply from: 'http://kaedea.github.com/gradle-maven-publication/gradle/bintray.gradle'

Run the following tasks to publish to Bintray:

gradle :bintrayUpload

Plugin

Publication plugin works in the same way of maven.gradle but much simpler.

  1. Apply the 'com.kaedea.publication' plugin.
  2. Config the properties.
  3. Run tasks to publish artifacts to local/remote repository.

Apply plugin like:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.kaedea:publication:latest.integration'
    }
}
apply plugin: 'com.kaedea.publication'

Config the plugin:

publication {
    GROUP('com.kaedea')
    VERSION_NAME('0.1.0-SNAPSHOT')

    RELEASE_REPOSITORY_URL('')
    SNAPSHOT_REPOSITORY_URL('')
    NEXUS_USERNAME('')
    NEXUS_PASSWORD('')

    uploadToBintray = true
    BINTRAY_REPO('maven')
    BINTRAY_USERNAME('kaedea')
    BINTRAY_API_KEY('bintray_api_key')
}

Now, here you go with the publish tasks

gradle :uploadArchives
gradle :bintrayUpload

Advanced Configuration

There are much more extra configurations of both scripts and plugin.

For Script

# 'optional': be configured or not
# 'required': must be configurated
# 'required here or system env': must be configurated in project properties or system environment

# ----------
# Maven repository config
# ----------
RELEASE_REPOSITORY_URL=  (required here or system env)
SNAPSHOT_REPOSITORY_URL= (required here or system env)

NEXUS_USERNAME= (required here or system env)
NEXUS_PASSWORD= (required here or system env)

POM_URL=https://github.com/kaedea/gradle-maven-publication/                   (optional)
POM_SCM_URL=https://github.com/kaedea/gradle-maven-publication/               (optional)
POM_SCM_CONNECTION=scm:[email protected]:kaedea/gradle-maven-publication.git     (optional)
POM_SCM_DEV_CONNECTION=scm:[email protected]:kaedea/gradle-maven-publication.git (optional)

POM_LICENCE_NAME=The Apache Software License, Version 2.0      (optional)
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt (optional)
POM_LICENCE_DIST=repo                                          (optional)

POM_DEVELOPER_ID=kaedea           (optional)
POM_DEVELOPER_NAME=Kaede Akatsuki (optional)

# ----------
# Maven artifact config
# ----------
GROUP=com.kaedea            (required)
VERSION_NAME=0.1.0-SNAPSHOT (required)

POM_NAME=Publication                                   (optional)
POM_ARTIFACT_ID=publication                            (optional)
POM_PACKAGING=jar|aar                                  (optional)
POM_DESCRIPTION=Gradle plugin that make the publishing (optional)

# ----------
# Bintray auth config
# ----------
BINTRAY_USERNAME= (required here or system env)
BINTRAY_API_KEY=  (required here or system env)

# ----------
# Maven repo config
# ----------
BINTRAY_REPO=maven       (required)
BINTRAY_NAME=publication (optional)

For Plugin

// You can configure the publishing in the following, or gradle.properties, or System.env
// The configuration is almost the same with scripts above
// 'optional': be configured or not
// 'required': must be configured
// 'required input': be configured, or the console will ask you to input the value

publication {
    jarSources = true // optional
    jarJavaDoc = true // optional
    jarTests = true   // optional

    GROUP('com.kaedea')            // required
    VERSION_NAME('0.1.0-SNAPSHOT') // required

    POM_NAME('Publication')        // optional
    POM_ARTIFACT_ID('publication') // optional
    POM_PACKAGING('jar')           // optional
    POM_URL('https://github.com/kaedea/publication/')         // optional
    POM_DESCRIPTION('Gradle plugin that make the publishing') // optional

    POM_SCM_URL('https://github.com/kaedea/publication/')                         // optional
    POM_SCM_CONNECTION('scm:git:git://github.com/kaedea/publication.git')         // optional
    POM_SCM_DEV_CONNECTION('scm:git:ssh://[email protected]:kaedea/publication.git') // optional

    POM_LICENCE_NAME('The Apache Software License, Version 2.0')      // optional
    POM_LICENCE_URL('http://www.apache.org/licenses/LICENSE-2.0.txt') // optional
    POM_LICENCE_DIST('repo')                                          // optional

    POM_DEVELOPER_ID('kaedea')           // optional
    POM_DEVELOPER_NAME('Kaede Akatsuki') // optional

    RELEASE_REPOSITORY_URL('')  // required
    SNAPSHOT_REPOSITORY_URL('') // required
    NEXUS_USERNAME('')          // required input
    NEXUS_PASSWORD('')          // required input

    uploadToBintray = true             // optional, to enable bintrayUpload
    BINTRAY_REPO('maven')              // required
    BINTRAY_NAME('publication')        // optional
    BINTRAY_USERNAME('kaedea')         // required input
    BINTRAY_API_KEY('bintray_api_key') // required input
}

References

  1. https://docs.gradle.org/current/userguide/maven_plugin.html
  2. https://docs.gradle.org/current/userguide/publishing_maven.html
  3. https://github.com/square/picasso/blob/master/gradle/gradle-mvn-push.gradle
  4. https://github.com/dcendents/android-maven-gradle-plugin
  5. https://stackoverflow.com/questions/26874498/maven-publish-android-library-with-aar-and-source-jar

Contributing

Check CONTRIBUTING.md.

License

The project is Apache License, Version 2.0 licensed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.