Publish an Android library to Maven with AAR and sources JAR
Asked Answered
M

7

105

Can somebody give me a hint on how to use the maven-publish Gradle plugin to publish a com.android.library project/module with AAR and source jar? I am able to do this with the old maven plugin - but I would like to use the new maven-publish plugin.

Manifold answered 11/11, 2014 at 21:1 Comment(1)
See this similar post.Stoltzfus
R
109

Here's a sample using the new maven-publish plugin.

apply plugin: 'maven-publish'

task sourceJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier "sources"
}

publishing {
    publications {
        bar(MavenPublication) {
            groupId 'com.foo'
            artifactId 'bar'
            version '0.1'
            artifact(sourceJar)
            artifact("$buildDir/outputs/aar/bar-release.aar")
        }
    }
    repositories {
        maven {
            url "$buildDir/repo"
        }
    }
}

Publish with ./gradlew clean build publish

Revenant answered 24/2, 2015 at 19:41 Comment(10)
Dependencies seem not to be recorded in the generated pom.Humbuggery
Use this plugin, it generates dependencies into pom as well: github.com/wupdigital/android-maven-publishPaoting
This worked for me after I replaced classifier "source" with classifier "sources".Irrelievable
Invalid publication 'library': multiple artifacts with the identical extension and classifier ('aar', 'null').Clementineclementis
I'm also getting the Invalid publication 'library': multiple artifacts with the identical extension and classifier ('aar', 'null'). message as well. @mudit_sen, did you find a way to resolve this?Drape
Heres a demo project with multi-module,android.gradle,kotlin-dsl, maven publishing and source-jars: github.com/danbrough/jitpackdemoFax
@Drape this is quite late but hopefully this'll help someone else. I ran in to a similar issue with the "multiple artifacts" error. I'm working on a project that uses the Android Gradle plugin 3.2.1 and it has some restrictions at the moment that are preventing me from updating to the latest gradle plugin version. That said I'm using the wupdigital android-maven-publish plugin. To resolve the "multiple artifacts" error, I simply removed the artifact() calls from publication as the plugin apparently already adds that for you.Psyche
In my trails I have noticed this is the correct answer. Without repositories block in publishing files are not generated even though tasks ends with a success message. What I wonder is then how jitpack.io is able to do it with the same codebase on their platform. Do they inject additional tasks or script files? Strange.Epizootic
classifier "sources" was removed in gradle 8.0Irreversible
I'm getting :generateMetadataFileForReleasePublication FAILED with the latest Studio and gradle plugin versionYellowish
K
144

With Android Gradle Plugin 7.1 it is now very simple to do this without needing any complicated scripts. AGP now also handles creating source and javadocs jar.

You don't need any separate scripts, just write everything into your build.gradle file of your module:

plugins {
    ...
    id 'maven-publish'
}
android {
    ...
    publishing {
        singleVariant("release") {
            // if you don't want sources/javadoc, remove these lines
            withSourcesJar()
            withJavadocJar()
        }
    }
}
afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId 'com.example'
                artifactId 'mylibrary'
                version '1.0.0'
            }
        }
    }
}

See official docs: https://developer.android.com/build/publish-library


Old answer

Since release of Android Studio 3.6 the support for building AAR (or even APK and AAB) is implemented in Android Gradle plugin 3.6.0 (and newer).

We don't need to handle the XML dependencies and stuff ourselves anymore.

Here is my updated Gist for Android Studio 3.6.0: https://gist.github.com/Robyer/a6578e60127418b380ca133a1291f017

Code from gist:

apply plugin: 'maven-publish'

task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    android.libraryVariants.all { variant ->
        if (variant.name == 'release') {
            owner.classpath += variant.javaCompileProvider.get().classpath
        }
    }
    exclude '**/R.html', '**/R.*.html', '**/index.html'
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    archiveClassifier.set('javadoc')
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    archiveClassifier.set('sources')
    from android.sourceSets.main.java.srcDirs
}

// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
    publishing {
        publications {
            // Creates a Maven publication called "release".
            release(MavenPublication) {
                // Applies the component for the release build variant.
                from components.release

                // Adds javadocs and sources as separate jars.
                artifact androidJavadocsJar
                artifact androidSourcesJar

                // You can customize attributes of the publication here or in module's build.gradle file (if you save this as script and include it build.gradle file, then you can just replicate this whole block there only with changed fields).
                //groupId = 'com.example'
                //artifactId = 'custom-artifact'
                version = android.defaultConfig.versionName // or just '1.0'
            }
        }
    }
}

Original answer:

Here is my improved solution, based on other answers.

Gist: https://gist.github.com/Robyer/a6578e60127418b380ca133a1291f017

Changes from other answers:

  • Changed classifier - it must be "sources" (not "source")
  • Handles dependencies
    • Supports also @aar and transitive: false. In that case we set exclusion in POM to ignore all transitive dependencies of this dependency.

    • Supports also custom exclude rules on dependencies, e.g.:

        compile('com.example:something:1.0', {
            exclude group: 'com.exclude.this', module: 'some-module'
        })
      
  • Doesn't need to specify artifact path manually.

apply plugin: 'maven-publish'

task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    android.libraryVariants.all { variant ->
        if (variant.name == 'release') {
            owner.classpath += variant.javaCompile.classpath
        }
    }
    exclude '**/R.html', '**/R.*.html', '**/index.html'
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    classifier = 'javadoc'
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}

project.afterEvaluate {
    publishing {
        publications {
            maven(MavenPublication) {
                //groupId 'cz.example'
                //artifactId 'custom-artifact'
                //version = android.defaultConfig.versionName
    
                artifact bundleReleaseAar
                artifact androidJavadocsJar
                artifact androidSourcesJar
    
                pom.withXml {
                    final dependenciesNode = asNode().appendNode('dependencies')
    
                    ext.addDependency = { Dependency dep, String scope ->
                        if (dep.group == null || dep.version == null || dep.name == null || dep.name == "unspecified")
                            return // ignore invalid dependencies
    
                        final dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', dep.group)
                        dependencyNode.appendNode('artifactId', dep.name)
                        dependencyNode.appendNode('version', dep.version)
                        dependencyNode.appendNode('scope', scope)
    
                        if (!dep.transitive) {
                            // If this dependency is transitive, we should force exclude all its dependencies them from the POM
                            final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
                            exclusionNode.appendNode('groupId', '*')
                            exclusionNode.appendNode('artifactId', '*')
                        } else if (!dep.properties.excludeRules.empty) {
                            // Otherwise add specified exclude rules
                            final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
                            dep.properties.excludeRules.each { ExcludeRule rule ->
                                exclusionNode.appendNode('groupId', rule.group ?: '*')
                                exclusionNode.appendNode('artifactId', rule.module ?: '*')
                            }
                        }
                    }
    
                    // List all "compile" dependencies (for old Gradle)
                    configurations.compile.getDependencies().each { dep -> addDependency(dep, "compile") }
                    // List all "api" dependencies (for new Gradle) as "compile" dependencies
                    configurations.api.getDependencies().each { dep -> addDependency(dep, "compile") }
                    // List all "implementation" dependencies (for new Gradle) as "runtime" dependencies
                    configurations.implementation.getDependencies().each { dep -> addDependency(dep, "runtime") }
                }
            }
        }
    }
}
Kolkhoz answered 10/2, 2017 at 13:30 Comment(38)
def dependencyNode = dependenciesNode.appendNode('dependency') throws an exception Could not get unknown property 'dependenciesNode' for object of type org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication.Baptista
@Baptista Is it possible that you are using old version of Gradle / Gradle plugin? It works for me correctly in Android Studio 2.2.3 with Gradle plugin 2.2.3 which uses Gradle 2.14.1.Kolkhoz
@wkarl Thank your for fixing the "more exclusions" branch. I just fixed formatting and missing } at the end.Kolkhoz
Changed classifier - it must be "sources" (not "source") helps me a lot!!Galasyn
groups.google.com/forum/#!topic/adt-dev/kzbEHAGbFVg has the solution for the "Could not get unknown property 'bundleRelease' "Hang
I updated my answer to support "api" dependencies in new Gradle. (again, now it should be correct)Kolkhoz
keep getting this error: Could not get unknown property 'bundleRelease' for object of type org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication. any ideas?Guntar
@takecare: bundleRelease is now called bundleReleaseAar. Thanks to this answer by Artem ZinnatullinAnimality
In new gradle it throws error again with bundleReleaseAar, but it seems we just have to wrap whole publishing block into project.afterEvaluate { publishing { ... } }. Then it works again. (I updated the answer just now)Kolkhoz
It is really necessary to do pom.withXml manually? There is no default implementation which handles it? It looks that there are is nothing directly specific for Android? Your implementation, for example, miss <classifier> tag and completely doesn't work if you are using BOM docs.gradle.org/5.0/userguide/…Sheets
@Sheets Maven Publishing plugin seems really simple, so I think it is necessary to do it manually. See docs.gradle.org/current/userguide/publishing_maven.html I don't know about these optional/advanced stuff like classifier or BOM. I just needed some simple publishing script and I compiled my answer and script from other answers and my needs. If you need something more, you can improve my gist on GitHub or use some completely different solution.Kolkhoz
Thanks a lot @Robyer, this is what exactly I was looking for.Ganef
For me, even after wrapping in project.afterEvaluate I get the error "Could not get unknown property 'bundleReleaseAar'". I wonder if another update messed things up?Anachronistic
Note that if you add dependencies to your specific flavor, it is necessary to include these in the pom.withXml. E. g. for release flavor: configurations.releaseImplementation.getDependencies().each { dep -> addDependency(dep, "runtime") }Mira
New Android Studio 3.6 with Android Gradle Plugin 3.6.0 has now support for Maven Publish Plugin. This script is probably not needed anymore. But I haven't tested it. See developer.android.com/studio/build/maven-publish-pluginKolkhoz
I just updated the script for use with Android Studio 3.6.Kolkhoz
@Kolkhoz I followed your guide and published my android library locally but when I use it in my other android projects it only recognises the resources files while I cannot reference my sources. I noticed that in the aar classes.jar file there's a ".kotlin_module" file. Do I have to add something because the library was written in kotlin?Sawdust
@Sawdust On my gist page was someone saying he has problem with Kotlin sources too, but unfortunately I don't use Kotlin and so I can't help with that.Kolkhoz
@Kolkhoz That's very unfortunate :(Sawdust
Wait, all I have to do is to write this into gradle, run it, and that's it? Shouldn't there be an account to register to? Or something? Otherwise doesn't it mean that everyone could publish into what I've made, no?Llovera
@androiddeveloper This code let you create the AAR and publish it to local maven repository (on your computer, via gradle task publishToMavenLocal). If you want to upload it to some remote maven repository, you need a bit more code. You can see example of such usage (in this case for Bintray repository) here: github.com/adaptech-cz/Tesseract4Android/blob/master/…Kolkhoz
@Kolkhoz I didn't get how to publish on maven-central, sadly. Instead I've found that I can publish via Jitpack, when I put the aar file together with 2 files into Github: reddit.com/r/android_devs/comments/m17bk6/…Llovera
@androiddeveloper For publishing on maven-central you can read for example this tutorial: proandroiddev.com/…Kolkhoz
@Kolkhoz Thank you. Do you know perhaps if it's worth it, if I found (and succeeded) how to do it on Jitpack? Does it have some advantages over Jitpack?Llovera
@androiddeveloper Some people advice against JitPack in this discussion reddit.com/r/androiddev/comments/lbssfn/… It seems JitPack is much easier to use for developer, but Maven Central is more secure for the user (requires verification that you own the domain that is used as your groupId), so it's up to your preference.Kolkhoz
@Kolkhoz Hmmmm... Doesn't seem like a definite conclusion can be made from this. Did you use maven-central? How long does it take to configure it? Did you get any issues from it?Llovera
@androiddeveloper We are far from the original topic here, you should discuss this somewhere else. But to answer - I was using only Bintray jcenter so far, but it is ending in next months so I need to move somewhere else. I haven't decided whether move to Jitpack or Maven Central yet.Kolkhoz
@Kolkhoz OK thanks. If you wish, I've succeeded making a POC of using Jitpack&Github. Wrote about this here: https://mcmap.net/q/138334/-how-to-serve-aar-files-using-jitpack Might be useful for you.Llovera
@Kolkhoz I've noticed there are 2 tasks here for JavaDocs. What's supposed to occur when using this? I see that it causes an error (I have only Kotlin code, if that matters) : > Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '...\build\tmp\androidJavadocs\javadoc.options' . Is it related to that I wrote the entire code in Kotlin and not in Java?Llovera
@androiddeveloper androidJavadocs creates the javadocs and androidJavadocsJar creates a *.jar file from it for publishing. This probably doesn't work with Kotlin code, but someone forked my gist to add some support for it. See there: gist.github.com/Robyer/…Kolkhoz
@Kolkhoz I see. Weird that Google made "Kotlin first" statement, and such a thing is missing...Llovera
I updated the answer for new Android Gradle Plugin 7.1 which greatly simplifies this task.Kolkhoz
What is the purpose of adding afterEvaluate when publishing? It seems to be working fine for me without itMillian
@YousefGamal There has been this comment in the docs: Because the components are created only during the afterEvaluate phase, you must configure your publications using the afterEvaluate() lifecycle method.Kolkhoz
Hi @Kolkhoz > This code let you create the AAR and publish it to local maven repository (on your computer, via gradle task publishToMavenLocal It doesn't create the .aar files or .pom file or the hash files. It just creates module.json and pom-default.xml in build/publications/release path. Nothing else. But once a local repository is added in publishing block's repositories with name and url all the .aar/.pom/hash files are generated without any problem. Is there something missing?Epizootic
Error: Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :MyProject project caused this errorGoyette
@KuvonchbekYakubov What you are trying to do is not supported by the way Maven artifacts works. When you are publishing your library, you are sending just the compiled binary (in JAR or AAR format), together with XML file which describes dependencies your binary requires - just a list of identifiers, similar to what is in the dependencies block in your build.gradle file. And since you are depending on some local AAR file which maven server can't know (it exists only on your computer), it cannot be specified as a dependency there, thus clients of your library won't get it and have broken build.Kolkhoz
@KuvonchbekYakubov Simply put, don't use local AAR dependencies in libraries you want to publish. Always specify and consume them as standard Maven dependencies. If you need more help, create new Stack Overflow question regarding that.Kolkhoz
R
109

Here's a sample using the new maven-publish plugin.

apply plugin: 'maven-publish'

task sourceJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier "sources"
}

publishing {
    publications {
        bar(MavenPublication) {
            groupId 'com.foo'
            artifactId 'bar'
            version '0.1'
            artifact(sourceJar)
            artifact("$buildDir/outputs/aar/bar-release.aar")
        }
    }
    repositories {
        maven {
            url "$buildDir/repo"
        }
    }
}

Publish with ./gradlew clean build publish

Revenant answered 24/2, 2015 at 19:41 Comment(10)
Dependencies seem not to be recorded in the generated pom.Humbuggery
Use this plugin, it generates dependencies into pom as well: github.com/wupdigital/android-maven-publishPaoting
This worked for me after I replaced classifier "source" with classifier "sources".Irrelievable
Invalid publication 'library': multiple artifacts with the identical extension and classifier ('aar', 'null').Clementineclementis
I'm also getting the Invalid publication 'library': multiple artifacts with the identical extension and classifier ('aar', 'null'). message as well. @mudit_sen, did you find a way to resolve this?Drape
Heres a demo project with multi-module,android.gradle,kotlin-dsl, maven publishing and source-jars: github.com/danbrough/jitpackdemoFax
@Drape this is quite late but hopefully this'll help someone else. I ran in to a similar issue with the "multiple artifacts" error. I'm working on a project that uses the Android Gradle plugin 3.2.1 and it has some restrictions at the moment that are preventing me from updating to the latest gradle plugin version. That said I'm using the wupdigital android-maven-publish plugin. To resolve the "multiple artifacts" error, I simply removed the artifact() calls from publication as the plugin apparently already adds that for you.Psyche
In my trails I have noticed this is the correct answer. Without repositories block in publishing files are not generated even though tasks ends with a success message. What I wonder is then how jitpack.io is able to do it with the same codebase on their platform. Do they inject additional tasks or script files? Strange.Epizootic
classifier "sources" was removed in gradle 8.0Irreversible
I'm getting :generateMetadataFileForReleasePublication FAILED with the latest Studio and gradle plugin versionYellowish
B
35

A little tweak to dskinners answer with correct dependency generation:

apply plugin: 'maven-publish'

task sourceJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier "source"
}

publishing {
    publications {
        bar(MavenPublication) {
            groupId 'com.foo'
            artifactId 'bar'
            version '0.1'
            artifact(sourceJar)
            artifact("$buildDir/outputs/aar/bar-release.aar")
            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')
                //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
                configurations.compile.allDependencies.each {
                    if(it.group != null && (it.name != null || "unspecified".equals(it.name)) && it.version != null)
                    {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
            }
        }
    }
    repositories {
        maven {
            url "$buildDir/repo"
        }
    }
}

And you can change version and groupId by defining:

version = '1.0.0'
group = 'foo.bar'
Bodine answered 31/8, 2016 at 14:23 Comment(2)
Instead of hardcoding the aar filename one can use artifact bundleRelease. Also the condition (it.name != null || "unspecified".equals(it.name)) does not look correct. Did you mean (it.name != null && "unspecified" != it.name)?Cimbri
How to include a dependency on project module?Mulley
P
24

If you want to avoid boilerplate codes, because the maven-publish plugin do not write dependencies into pom.xml

Try this plugin: android-maven-publish

publishing {
    publications {
        mavenAar(MavenPublication) {
            groupId 'com.example'
            artifactId 'mylibrary'
            version '1.0.0'
            from components.android
        }
    }

    repositories {
        maven {
            url "$buildDir/releases"
        }
    }
}

Update:

android-maven-publish plugin is deprecated, since maven-publish is officially supported by AGP.

Paoting answered 4/8, 2017 at 19:39 Comment(8)
Thanks for the link bvarga. Does that plugin take care of adding dependency exclusions in the generated pom file?Rondelet
bvarga, I just tried it and yes it does! Thanks for bringing this plugin to my attention. It works like a charm!Rondelet
This is by far the best solution to the problem. Should be accepted IMO.Disk
in wich folder is the maven repo generated?.I tried ./gradlew clean build publish but is not working –Cymbiform
@HermanZun see updated answer. You can specify the repository wherever you want.Witten
It's my understanding that the bundleReleaseAar command will allow you to upload a completed build with the bintrayUpload gradle task. Does android-maven-plugin allow the same thing? Or do you have to build the .aar file first and then publish?Anachronistic
bundleReleaseAar task builds the artifact. The android-maven-plugin uses this task under the hood. When you set components.android on your publication it will pass the output of bundleReleaseAar task to the publication (artifacts and deps)Paoting
android-maven-publish plugin is deprecated, since maven-publish is officially supported by AGP. Use AGP 3.6.0 or newer.Paoting
S
4

Here is how I included Dokka (view it online) and sources JARs for my Android Kotlin library using Kotlin DSL (build.gradle.kts):

plugins {
    // ...
    id("org.jetbrains.dokka") version "1.4.32"
    id("maven-publish")
}

lateinit var sourcesArtifact: PublishArtifact
lateinit var javadocArtifact: PublishArtifact

tasks {
    val sourcesJar by creating(Jar::class) {
        archiveClassifier.set("sources")
        from(android.sourceSets["main"].java.srcDirs)
    }
    val dokkaHtml by getting(org.jetbrains.dokka.gradle.DokkaTask::class)
    val javadocJar by creating(Jar::class) {
        dependsOn(dokkaHtml)
        archiveClassifier.set("javadoc")
        from(dokkaHtml.outputDirectory)
    }
    artifacts {
        sourcesArtifact = archives(sourcesJar)
        javadocArtifact = archives(javadocJar)
    }
}

publishing {
    // ...
    publications {
        create<MavenPublication>("MyPublication") {
            from(components["release"])
            artifact(sourcesArtifact)
            artifact(javadocArtifact)
            // ...
        }
    }
}
Stoltzfus answered 18/2, 2022 at 11:38 Comment(0)
H
2

Using Kotlin build.gradle.kts:

publishing.publications {
    register<MavenPublication>("aar") {
        groupId = "com.foo"
        artifactId = "bar"
        version = "0.1"

        artifact("$buildDir/outputs/aar/bar-release.aar")

        pom.withXml {
            val dependencies = asNode().appendNode("dependencies")

            val addNode = { groupId: String, artifactId: String, version: String ->
                val dependency = dependencies.appendNode("dependency")
                dependency.appendNode("groupId", groupId)
                dependency.appendNode("artifactId", artifactId)
                dependency.appendNode("version", version)
            }

            addNode("com.example", "dependency-name", "1.0")
        }
    }
}
Hypnology answered 15/12, 2022 at 14:48 Comment(2)
Thanks for the clear example. How do you actually publish it though?Powys
@Powys This is outside the scope of the original question, but we are using jfrog so we also have artifactory { ... } in the build file. This may help: jfrog.com/help/r/jfrog-integrations-documentation/…Hypnology
M
-2

You can also use the android maven plugin. It creates the .aar, javadoc.jar, sources.jar and .pom and updates the maven-metadata.xml after uploading the files to the maven repository. I also put the script on GitHub.

apply plugin: 'com.android.library'
apply plugin: 'maven'

//Your android configuration
android {
    //...
}

//maven repository info
group = 'com.example'
version = '1.0.0'

ext {
    //Specify your maven repository url here
    repositoryUrl = 'ftp://your.maven.repository.com/maven2'
    //Or you can use 'file:\\\\C:\\Temp' or 'maven-temp' for a local maven repository
}

//Upload android library to maven with javadoc and android sources
configurations {
    deployerJars
}

//If you want to deploy to an ftp server
dependencies {
    deployerJars "org.apache.maven.wagon:wagon-ftp:2.2"
}

// custom tasks for creating source/javadoc jars
task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    destinationDir = file("../javadoc/")
    failOnError false
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

//Creating sources with comments
task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}

//Put the androidSources and javadoc to the artifacts
artifacts {
    archives androidSourcesJar
    archives javadocJar
}

uploadArchives {
    repositories {
        mavenDeployer {
            configuration = configurations.deployerJars
            repository(url: repositoryUrl) {
                //if your repository needs authentication
                authentication(userName: "username", password: "password")
            }
        }
    }
}

Call it with

./gradlew uploadArchives
Mooncalf answered 14/8, 2016 at 8:52 Comment(1)
The whole point of the question was to use the maven-publish plugin instead of the old way with the maven plugin.Cimbri

© 2022 - 2024 — McMap. All rights reserved.