Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am just changing from eclipse to android studio. To have the benefits, gradle is teaching us, I am trying to set up a local repository using jForgs Artifacts. Now I am facing the problem, that I want to push/publish a library I have written in Android Studio to artifacts so I can easily import it via a depency in my next android App project.
The Folder structure looks like this:
LibDeploy
build.gradle
gradle.properties
-> app
--> build
--> libs
--> src
--> main
--> java
build.gradle
-> gradle
--> wrapper
my gradle.build in the app folder look like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.0'
classpath 'com.github.dcendents:android-maven-plugin:1.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3'
}
}
import java.text.SimpleDateFormat
def globalVersion = new Version(currentVersion)
// Define the artifacts coordinates
group = 'org.jfrog.example.android'
version = globalVersion
status = version.status
// Plugins
apply plugin: 'com.android.library'
apply plugin: 'artifactory'
// We need the patched maven plugin since 'install' task is overriden by 'installDebugTest', see: https://github.com/dcendents/android-maven-plugin
apply plugin: 'android-maven'
// Android
android {
compileSdkVersion 21
buildToolsVersion "21.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
}
}
configurations {
published
}
task sourceJar(type: Jar) {
from android.sourceSets.main.java
classifier "sources"
}
artifactoryPublish {
dependsOn sourceJar
}
artifacts {
published sourceJar
}
configure(install.repositories.mavenInstaller) {
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
artifactory {
contextUrl = 'http://localhost:8080/artifactory'
publish {
repository {
repoKey = 'libs-snapshot-local' //The Artifactory repository key to publish to
username = artifactory_user //The publisher user name, property taken from gradle.properties
password = artifactory_password //The publisher password, property taken from gradle.properties
}
defaults {
publishConfigs('archives', 'published')
properties = ['build.status': "$it.project.status".toString()]
publishPom = true //Publish generated POM files to Artifactory (true by default)
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default)
}
}
resolve {
repository {
repoKey = 'libs-release' //The Artifactory (preferably virtual) repository key to resolve from
username = artifactory_user //Optional resolver user name (leave out to use anonymous resolution), property taken from gradle.properties
password = artifactory_password //The resolver password, property taken from gradle.properties
}
}
}
repositories {
jcenter()
}
// Our project dependencies
dependencies {
compile 'joda-time:joda-time:2.3'
// Backward compatibility for andoird <http://developer.android.com/tools/support-library/index.html>
//compile 'com.android.support:support-v4:19.1.+'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
class Version {
String thisVersion = 'default'
String status = 'default'
Version(String versionValue) {
thisVersion = versionValue
if (thisVersion.endsWith('-SNAPSHOT')) {
status = 'integration'
} else {
status = 'release'
}
}
String toString() {
thisVersion
}
}
When I am trying to push/publish to artifactory via gradlew artifactoryPublish
I am getting the error:
:app:sourceJar
FAILURE: Build failed with an exception.
* What went wrong:
Cannot convert the provided notation to a File or URI: [src/main/java].
The following types/formats are supported:
- A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
- A String or CharSequence URI, e.g 'file:/usr/include'
- A File instance.
- A URI or URL instance.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
I think the problem should be in this line in the build.gradle file
task sourceJar(type: Jar) {
from android.sourceSets.main.java
classifier "sources"
}
Does anybody have a great tut how to set up a central maven repo for our build process?
Thanks in advance!
I solved this by changing
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main
}
to
task sourcesJar(type: Jar) {
classifier = 'sources'
from 'src/main/java'
}
Related
I am working on Android library development, i have already finished my library work and generated aar and jar file, but when i am trying to publish to binary at that time i am getting one error message.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mylittlelibrary:bintrayUpload'.
> Could not create package 'abcd/maven/helloaar.example.com.mylittlelibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.391 secs
Could not create package 'abcd/maven/helloaar.example.com.mylittlelibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
2:41:59 AM: External task execution finished 'bintrayUpload'.
build.gradle
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
repositories {
mavenCentral()
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0-beta1'
}
group = 'helloaar.example.com.mylittlelibrary'
version = '1.0.2'
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
task generateJavaDocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath()
.join(File.pathSeparator))
}
task generateJavaDocsJar(type: Jar) {
from generateJavaDocs.destinationDir
classifier 'javadoc'
}
generateJavaDocsJar.dependsOn generateJavaDocs
bintray {
user = 'abcd'
key = '1234567890fghgfhffjfgjfjfjrtyjtkjg'
pkg {
repo = 'maven'
name = 'helloaar.example.com.mylittlelibrary'
version {
name = '1.0.2'
desc = 'My test upload'
released = new Date()
vcsTag = '1.0.2'
}
licenses = ['Apache-2.0']
vcsUrl = ''
websiteUrl = ''
}
configurations = ['archives']
}
artifacts {
archives generateJavaDocsJar
archives generateSourcesJar
}
Please kindly go through my script and suggest me some solution.
Before you publish to Bintray you must have a stable build of your code.
The hierarchy on Bintray is the following:
User --> Repo --> package --> version --> artifact
means that the Repo should be above the package by that hierarchy.
The following lines in your gradle.build are probably the main cause for the error:
pkg {
repo = 'maven'
name = 'helloaar.example.com.mylittlelibrary'
}
The hierarchy is wrong.
When using maven you should check that you comply with the maven convention, else the Maven Build can not succeed. Explanation for Maven Repositories on Bintray.
The error you had:
HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
Means that you do not have a Repository on Bintray calls maven. All the packages versions and files should be under the Bintray Repository you have created.
For more details or support issues you can use the Bintray support team which is available for all Bintray users and can help you with any problem related to any JFrog platform services such as Bintray, Artifactory, Mission control & Xray.
pkg {
repo = 'maven'
name = 'helloaar.example.com.mylittlelibrary'
version {
name = '1.0.2'
desc = 'My test upload'
released = new Date()
vcsTag = '1.0.2'
}
Could not create package 'abcd/maven/helloaar.example.com.mylittlelibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
2:41:59 AM: External task execution finished 'bintrayUpload'.
'abcd/maven/helloaar.example.com.mylittlelibrary'
abcd : bintray user name
maven : pkg { repo = 'maven' } set by you, example 'abcd/android-lib/helloaar.example.com.mylittlelibrary' when set repo = 'android-lib'
helloaar.example.com.mylittlelibrary : pkg{ name = 'helloaar.example.com.mylittlelibrary'
-
first : check your bintray account,
second : make repository,
third : modify your pkg repo = 'input making repository name from second step' build.gradle
last : build again
i hope help for you, have a nice day
I have a library project with a module that is just for library classes and views. I've been searching over the internet how to distribute it in jCenter to use as a gradle dependency but nothing works.
While this isn't done yet, how can I use this module in others projects?
PS: I use Android Studio on Windows 10.
Many of the tutorials and directions online are out of date or are very hard to follow. I just learned how to do this myself, so I am adding what will hopefully be a quick solution for you. It includes the following points
Start with your Android library
Set up a Bintray account
Edit your project's gradle files
Upload your project to Bintray
Link it to jCenter
The library you want to share
By now you probably already have a library set up. For the sake of this example I made a new project with one demo-app application module and one my-library library module in Android Studio.
Here is what it looks like using both the Project and Android views:
Set up a Bintray account
Bintray hosts the jCenter repositories. Go to Bintray and set up a free account.
After you sign in click Add New Repository
Name the repository maven. (You can call it something else, though, if you want to group several library projects together. If you do you will also need to change the bintrayRepo name in the gradle file below.)
Chose Maven as the repository type.
You can add a description if you want. Then click Create. That's all we need to do in Bintray for now.
Edit the gradle files
I'm going to make this as cut-and-paste as possible, but don't forget to edit the necessary parts. You don't need to do anything with the demo app module's build.gradle file, only the gradle files for the project and the library.
Project build.gradle
Add the Bintray and Mavin plugins to your project build.gradle file. Here is my whole file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
// Add these lines (update them to whatever the newest version is)
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The newest version for Bintray is here and Maven is here.
Library build.gradle
Edit everything you need to in the ext block below.
apply plugin: 'com.android.library'
// change all of these as necessary
ext {
bintrayRepo = 'maven' // this is the same as whatever you called your repository in Bintray
bintrayName = 'my-library' // your bintray package name. I am calling it the same as my library name.
publishedGroupId = 'com.example'
libraryName = 'my-library'
artifact = 'my-library' // I'm calling it the same as my library name
libraryDescription = 'An example library to make your programming life easy'
siteUrl = 'https://github.com/example/my-library'
gitUrl = 'https://github.com/example/my-library.git'
libraryVersion = '1.0.0'
developerId = 'myID' // Maven plugin uses this. I don't know if it needs to be anything special.
developerName = 'My Name'
developerEmail = 'myemail#example.com'
licenseName = 'The MIT License (MIT)'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
}
// This next section is your normal gradle settings
// There is nothing special that you need to change here
// related to Bintray. Keep scrolling down.
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
// Maven section
// You shouldn't need to change anything. It just uses the
// values you set above.
apply plugin: 'com.github.dcendents.android-maven'
group = publishedGroupId // Maven Group ID for the artifact
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact
// Add your description here
name libraryName
description libraryDescription
url siteUrl
// Set your license
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
// Bintray section
// As long as you add bintray.user and bintray.apikey to the local.properties
// file, you shouldn't have to change anything here. The reason you
// don't just write them here is so that they won't be publicly visible
// in GitHub or wherever your source control is.
apply plugin: 'com.jfrog.bintray'
version = libraryVersion
if (project.hasProperty("android")) { // Android libraries
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
} else { // Java libraries
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = true
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
// optional GPG encryption. Default is false.
sign = false
//passphrase = properties.getProperty("bintray.gpg.password")
}
}
}
}
local.properties
The library build.gradle file above referenced some values in the local.properties file. We need to add those now. This file is located in the root of your project. It should be included in .gitignore. (If it isn't then add it.) The point of putting your username, api key, and encryption password here is so that it won't be publicly visible in version control.
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/home/yonghu/Android/Sdk
# Add these lines (but change the values according to your situation)
bintray.user=myusername
bintray.apikey=1f2598794a54553ba68859bb0bf4c31ff6e71746
There is a warning about not modifying this file but it seems to work well anyway. Here is how you get the values:
bintray.user: This is your Bintray username.
bintray.apikey: Go to Edit Profile in the Bintray menu and choose API Key. Copy it from here.
Upload project to Bintray
Open a terminal and go to your project's root folder. Or just use the terminal in Android Studio.
Enter the following commands
./gradlew install
./gradlew bintrayUpload
If everything is set up right it should upload your library to Bintray. If it fails then Google the solution. (I had to update my JDK the first time I tried.)
Go to your account in Bintray and you should see the library entered under your repository.
Link to jCenter
In your library in Bintray there is an Add to jCenter button.
Click it and send your request. If you are approved (which takes a day or two), then your library will be a part of jCenter and developers around the world can add your library to their projects simply by adding one line to the app build.gradle dependencies block.
dependencies {
compile 'com.example:my-library:1.0.0'
}
Congratulations!
Notes
You may want to add PGP encryption, especially if you are linking it to Maven Central. (jCenter has replaced Maven Central as the default in Android Studio, though.) See this tutorial for help with that. But also read this from Bintray.
How to add a new version
You will eventually want to add a new version to your Bintray/jCenter library. See this answer to directions on how to do it.
Further Reading
How to distribute your own Android library through jCenter and Maven Central from Android Studio
Creating and Publishing an Android Library
I've recently updated Android Studio to version 2.0 : Beta 7.
I'm trying to use Instant Run, I've just installed Gradle 2.0.
But now I can't compile my project due to an error related to bintray.gradle
When I compile I get the following error :
Error:Cannot configure the 'publishing' extension after it has been accessed.
Debugger Error :
Error:FAILURE: Build failed with an exception.
* Where:
Script 'C:\Project\AtkApp\volley\bintray.gradle' line: 43
* What went wrong:
A problem occurred evaluating script.
> Cannot configure the 'publishing' extension after it has been accessed.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Bintray.gradle :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2"
}
}
// apply the plugin with its class name rather than its Id to work around gradle limitation of
// not being able to find the plugin by Id despite the dependencies being added right above. Gradle
// is currently not capable of loading plugins by Id if the dependency is anywhere else than
// in the main project build.gradle. This file is "imported" into the project's build.gradle
// through a "apply from:".
apply plugin: com.jfrog.bintray.gradle.BintrayPlugin
apply plugin: 'maven-publish'
project.ext.group = 'com.android.volley'
project.ext.archivesBaseName = 'volley'
project.ext.version = '1.0.0'
project.ext.pomDesc = 'Volley Android library'
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
publishing {
publications {
library(MavenPublication) {
groupId project.ext.group
artifactId project.ext.archivesBaseName
version project.ext.version
// Release AAR, Sources, and JavaDoc
artifact "$buildDir/outputs/aar/volley-release.aar"
artifact sourcesJar
artifact javadocJar
}
}
}
bintray {
user = System.env.BINTRAY_USER
key = System.env.BINTRAY_USER_KEY
publications = [ 'library' ]
publish = project.has("release")
pkg {
userOrg = 'android'
repo = 'android-utils'
group = project.ext.group
name = project.ext.group + '.' + project.ext.archivesBaseName
desc = project.ext.pomDesc
licenses = [ 'Apache-2.0' ]
websiteUrl = 'https://tools.android.com'
issueTrackerUrl = 'https://code.google.com/p/android/'
vcsUrl = 'https://android.googlesource.com/platform/frameworks/volley.git'
labels = ['android', 'volley', 'network']
publicDownloadNumbers = true
version {
name = project.ext.version
desc = project.ext.pomDesc + ' version ' + project.ext.version
gpg {
sign = true
passphrase = System.env.GPG_PASSPHRASE
}
}
}
}
I have faced same problem when I update the latest version.
I tried do this and success.
The culprit is publishing tag used in bintray.gradle of Volley project.
With Gradle 2.0.0 update its complaining about publishing can't be configured after it has been accessed.
For now commenting following line in build.gradle of Volley project will get the build going.
//apply from: 'bintray.gradle'
I will updted the comment once have better solution.
Don't comment this line:
apply from: 'bintray.gradle'
just change these line of codes
publishing {
publications {
library(MavenPublication) {
groupId project.ext.group
artifactId project.ext.archivesBaseName
version project.ext.version
// Release AAR, Sources, and JavaDoc
artifact "$buildDir/outputs/aar/volley-release.aar"
artifact sourcesJar
artifact javadocJar
}
}
}
to
publishing.publications {
library(MavenPublication) {
groupId project.ext.group
artifactId project.ext.archivesBaseName
version project.ext.version
// Release AAR, Sources, and JavaDoc
artifact "$buildDir/outputs/aar/volley-release.aar"
artifact sourcesJar
artifact javadocJar
}
}
publishing{ publications{}}, it's in the volley files you added to your project. Don't waste time looking in the project gradle.
Gradle/maven newbie here. I have created a library that is currently published to bintray/jcenter as an AAR, to be used with gradle in Android Studio projects.
However, since my library doesn't really have any hard Android dependencies, and may be used in any Java SE environment, I would like to publish it also as a normal jar. Since I am not very familiar with the non-android java development community I am not sure if this means I should publish it to Maven central, or would developers typically be fine fetching my library from bintray, given that the library is actually hosted in a maven repo on bintray?
Should I simply extend my artifacts to include the jar (alongside with the aar, the javadoc and the source jar), or should I typically publish the jar separately, say to Maven central?
Getting the bintray/jcenter stuff up and running was no picnic, I found a few guides on how to do it, but none was really complete, but finally I have it working. I am however having a surprisingly difficult time finding a similar easy guide for maven publishing.
My gradle file looks like this:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 1
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
}
}
group = <my library name>
version = <my version>
dependencies {
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options.overview = 'src/main/overview.html'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = <my library name>
websiteUrl = <my site url>
vcsUrl = <my git url>
licenses = ["Apache-2.0"]
publish = true
}
}
The com.github.dcendents.android-maven plugin offers an install task that produces the AAR, Source Jar and Javadoc Jar. I have defined my own bintray task that publishes the library to bintray. What would be the easiest way to create a task for publishing my library also as a standard jar to maven? Can I use com.github.dcendents.android-maven for this as well, or do I need a separate plugin?
I am using Android Gradle plugin 0.13.2, Android Studio 0.8.11, Gradle 2.1 and maven plugin.
I would like to install multiple variants (flavour + build type) of my Android Library to local Maven repository all with one command (task).
Currently Android Gradle plugin 0.13.2 allows me to set publishNonDefault flag to publishing all variants, but as the documentation states it will publish the variants with a classifier which is not compatible with Maven Repository.
My workaround right now is to use defaultPublishConfig "myVariant" and change it for every variant I have.
apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
defaultPublishConfig "myVariant"
.
.
.
}
task installArchives(type: Upload) {
repositories.mavenInstaller {
configuration = configurations.getByName(Dependency.DEFAULT_CONFIGURATION)
pom.groupId = "com.company"
pom.artifactId = "mylibrary"
pom.version = "1.0.0-myVariant"
}
}
I would like to have a single task that would properly publish all variants to local Maven repository.
To solve this I had to create one Upload task for each variant and make them depend on each other and on a master task that starts the process.
apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
.
.
.
}
// Master task that will publish all variants
def DefaultTask masterTask = project.tasks.create("installArchives", DefaultTask)
android.libraryVariants.all { variant ->
variant.outputs.each { output ->
// Configuration defines which artifacts will be published, create one configuration for each variant output (artifact)
def Configuration variantConfiguration = project.configurations.create("${variant.name}Archives")
project.artifacts.add(variantConfiguration.name, output.packageLibrary)
// Create one Upload type task for each configuration
def Upload variantTask = project.tasks.create("${variant.name}Install", Upload)
variantTask.configuration = variantConfiguration
variantTask.repositories.mavenInstaller {
pom.groupId = "com.yourcompany"
pom.artifactId = "yourLibrary"
pom.version = "1.0.0-${variant.name}" //Give a different version for each variant
pom.packaging = "aar"
}
// Make all tasks depend on each other and on master task
masterTask.dependsOn variantTask
masterTask = variantTask
}
}
The task installArchives will publish all variants to the local Maven repository.
./gradlew installArchives