Git Product home page Git Product logo

rapidmavenpushplugin's Introduction

RapidMavenPushPlugin

Maven Central API

A Gradle plugin : Upload your library Artifacts to Multi Maven Repository.

中文版本

1. How to use

1.1 Dependencies

Add RapidMavenPushPlugin dependencies in build.gradle of your root project:

Newest Version: Maven Central

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 Create properties files

Now you have 3 maven types, so create 3 maven upload archive properties files & 1 common archive properties file (properties file's name & location can be arbitrary):

  • maven_local.properties: Upload archives to local maven repository, default in your computer is ~/.m2/repository.
  • maven_company.properties: Upload archives to your company's maven repository which deploy in your company server.
  • maven_central.properties: Upload archives to maven central repository.
  • common.properties: Common properties for 3 maven types above.

NOTE: When project.afterEvaluate, all properties are automatically injected into project.ext, so you can use it like $POM_ARCHIVE_ID after that.

1.2.1 maven_common.properties

# project info
POM_ARCHIVE_GROUP=com.github.wangjiegulu
#POM_ARCHIVE_VERSION_NAME=0.0.1-SNAPSHOT (command typed)
# aar or jar or unset(parse automatically by plugin)
#POM_PACKAGING=aar
POM_DESC=test-mavenpush-plugin
POM_URL=https://github.com/wangjiegulu
POM_SCM_URL=scm:[email protected]:wangjiegulu
POM_SCM_CONNECTION=scm:[email protected]:wangjiegulu
[email protected]:wangjiegulu
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=wangjie
POM_DEVELOPER_ID=wangjie
POM_DEVELOPER_NAME=Wang Jie
[email protected]

1.2.2 maven_local.properties

# maven repository
POM_REPOSITORY_URL=/Users/wangjie/.m2/repository
POM_REPOSITORY_URL_SNAPSHOT=/Users/wangjie/.m2/repository
POM_SIGN=false

# project info
POM_ARCHIVE_ID=mavenpush-plugin-depmodule-local

1.2.3 maven_central.properties

POM_OSSRH_USERNAME=username
POM_OSSRH_PASSWORD=password

# maven repository
POM_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 info
POM_ARCHIVE_ID=mavenpush-plugin-depmodule

1.3 Apply Plugin & properties

In build.gradle of your library, you need to apply RapidMaven PushPlugin as below:

apply plugin: 'com.github.wangjiegulu.plg.rapidmavenpush'

rapidMavenPush {
    // If true, print injected properties in compile time
    printProperties = true
    // If true, abort compile when inject properties error
    abortOnError = false
    // If disable Rapid Maven Push Plugin
    disable = false
    // Default maven type if `POM_MAVEN_TYPE` is not set.
    defaultMavenType = 'local'
    mavens {
        maven {
            mavenType = 'local'
            propertyFiles = [
                    file("mavenupload/maven_common.properties"),
                    file("mavenupload/maven_local.properties")
            ]
            // Property Inject Mode: If the properties is already set, replace it 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 compile, rapid maven push plugin created a task automatically named rapidUploadArchives.

Just run this task!

Upload archives to local repository:

./gradlew clean :depmodule:rapidUploadArchives -PPOM_MAVEN_TYPE=local

Upload archives to central repository:

./gradlew clean :depmodule:rapidUploadArchives -PPOM_MAVEN_TYPE=central

NOTE: POM_MAVEN_TYPE parameter is necessary if you haven't set it in build.gradle with ext.POM_MAVEN_TYPE=xxx.

1.5 Supported parameters & properties

// maven type, only `ext.POM_MAVEN_TYPE=xxx` in build.gradle or `-PPOM_MAVEN_TYPE=xxx` in command or `POM_MAVEN_TYPE=xxx` in `gradle.properties`.
POM_MAVEN_TYPE

// maven repository parameters
POM_REPOSITORY_URL
POM_REPOSITORY_URL_SNAPSHOT
POM_OSSRH_USERNAME
POM_OSSRH_PASSWORD

// sign parameters
POM_SIGN
signing.keyId
signing.password
signing.secretKeyRingFile

// archive parameters
POM_OPEN_SOURCE             // is open source archives(since v0.0.5), default true. if true, packaging with doc.jar & source.jar; if false, without doc.jar & source.jar.
POM_ARCHIVE_GROUP
POM_ARCHIVE_ID
POM_ARCHIVE_VERSION_NAME
POM_PACKAGING
POM_DESC
POM_URL
POM_SCM_URL
POM_SCM_CONNECTION
POM_SCM_DEV_CONNECTION
POM_LICENCE_NAME
POM_LICENCE_URL
POM_LICENCE_DIST
POM_DEVELOPER_ID
POM_DEVELOPER_NAME
POM_DEVELOPER_EMAIL

License

Copyright 2018 Wang Jie

Licensed 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.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.

rapidmavenpushplugin's People

Contributors

wangjiegulu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rapidmavenpushplugin's Issues

Error null

Hi i cannot understand my mistake.
My logs:

22:46:33: Executing task 'rapidUploadArchives'...

Executing tasks: [rapidUploadArchives] in project /Users/v.stelmashchuk/Desktop/Github/AttrAutoBind/annotation


> Configure project :annotation
+-----------------------------------------------------------------------------------+
|                      Rapid Maven Property Inject START                            |
+-----------------------------------------------------------------------------------+
[RapidMavenPushPlugin][WARN]RapidMavenPushType: null
[RapidMavenPushPlugin][INFO]Origin Packaging: null
[RapidMavenPushPlugin][INFO]Parsed Packaging: jar
[RapidMavenPushPlugin][ERROR][ERROR in 'RapidMavenPushTask']throwable: null

> Task :annotation:compileKotlin UP-TO-DATE
> Task :annotation:compileJava NO-SOURCE
> Task :annotation:processResources NO-SOURCE
> Task :annotation:classes UP-TO-DATE
> Task :annotation:inspectClassesForKotlinIC
> Task :annotation:jar
> Task :annotation:javadoc NO-SOURCE
> Task :annotation:javadocJar
> Task :annotation:sourcesJar
> Task :annotation:rapidUploadArchives

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 0s
6 actionable tasks: 5 executed, 1 up-to-date
22:46:34: Task execution finished 'rapidUploadArchives'.

My gradle file

apply plugin: 'java-library'
apply plugin: 'kotlin'

apply plugin: 'com.github.wangjiegulu.plg.rapidmavenpush'

rapidMavenPush {
    // If true, print injected properties in compile time
    printProperties = true
    // If true, abort compile when inject properties error
    abortOnError = false
    // If disable Rapid Maven Push Plugin
    disable = false
    // Default maven type if `POM_MAVEN_TYPE` is not set.
    defaultMavenType = 'local'
    mavens {
        maven {
            mavenType = 'central'
            propertyFiles = [
                    file("maven_common.properties"),
                    file("maven_central.properties")
            ]
            propertyInjectMode = 'replace'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

Error null

Hi i cannot understand my mistake.
My logs:

22:46:33: Executing task 'rapidUploadArchives'...

Executing tasks: [rapidUploadArchives] in project /Users/v.stelmashchuk/Desktop/Github/AttrAutoBind/annotation


> Configure project :annotation
+-----------------------------------------------------------------------------------+
|                      Rapid Maven Property Inject START                            |
+-----------------------------------------------------------------------------------+
[RapidMavenPushPlugin][WARN]RapidMavenPushType: null
[RapidMavenPushPlugin][INFO]Origin Packaging: null
[RapidMavenPushPlugin][INFO]Parsed Packaging: jar
[RapidMavenPushPlugin][ERROR][ERROR in 'RapidMavenPushTask']throwable: null

> Task :annotation:compileKotlin UP-TO-DATE
> Task :annotation:compileJava NO-SOURCE
> Task :annotation:processResources NO-SOURCE
> Task :annotation:classes UP-TO-DATE
> Task :annotation:inspectClassesForKotlinIC
> Task :annotation:jar
> Task :annotation:javadoc NO-SOURCE
> Task :annotation:javadocJar
> Task :annotation:sourcesJar
> Task :annotation:rapidUploadArchives

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 0s
6 actionable tasks: 5 executed, 1 up-to-date
22:46:34: Task execution finished 'rapidUploadArchives'.

My gradle file

apply plugin: 'java-library'
apply plugin: 'kotlin'

apply plugin: 'com.github.wangjiegulu.plg.rapidmavenpush'

rapidMavenPush {
    // If true, print injected properties in compile time
    printProperties = true
    // If true, abort compile when inject properties error
    abortOnError = false
    // If disable Rapid Maven Push Plugin
    disable = false
    // Default maven type if `POM_MAVEN_TYPE` is not set.
    defaultMavenType = 'local'
    mavens {
        maven {
            mavenType = 'central'
            propertyFiles = [
                    file("maven_common.properties"),
                    file("maven_central.properties")
            ]
            propertyInjectMode = 'replace'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

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.