How to publish aar file to Apache Archiva with Gradle

Marian Klühspies

I´m trying to publish the generated aar file of my android library to my Apache Archiva Maven server, but I haven´t manage to get it working yet because either the examples are outdated or they are for java and not for android

After noticing that most methods of the gradle examples are deprecated, I found this new documentation:

Gradle Documentation

Which describes how to use the new API which seems to replace uploadArchives with publishing and so on....

So this is what I´ve got so far:

apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'maven-publish'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"


defaultConfig {
    applicationId "com.mycompany.mylibrary"
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
lintOptions {
    abortOnError false
}

}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.android.support:appcompat-v7:21.0.3'
}

task sourceJar(type: Jar) {
    from sourceSets.main.allJava
}

publishing {

publications {
    mavenJava(MavenPublication) {
        groupId 'com.android.mylibrary'
        artifactId 'MyLibrary'
        version '1.0.0'

        from components.java

        artifact sourceJar {
            classifier "sources"
        }
    }
}
repositories {
    maven {
        url "myurl"
        credentials{
            username "user"
            password "password"
        }
    }
}
}

The Gradle stuff is like the hell for me. I don´t know what is right and what is wrong and some things seem to be changed without any hints that it isn´t supported anymore, which makes it quite difficult to solve these problems...

How can I automatically upload the generated aar file to my Apache Archiva?

Marian Klühspies

Solved it by myself

apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'maven-publish'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"


repositories {
    mavenCentral()
}

defaultConfig {
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


dependencies {
   compile fileTree(include: ['*.jar'], dir: 'libs')
   provided 'com.android.support:support-v4:21.0.3'
   provided 'com.android.support:appcompat-v7:21.0.3'
}

task sourceJar(type: Jar) {
   classifier "source"
}

publishing {
   publications {

       repositories.maven {
           url 'myurl/repositories/myrepo'
           credentials {
               username "user"
               password "password"
           }
       }

       maven(MavenPublication) {
           artifacts {
               groupId 'com.mycompany'
               artifactId 'mylibrary'
               version '1.0'
               artifact 'build/outputs/aar/app-release.aar'
           }
       }
   }

}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Publish an aar file to Maven Central with Gradle not working

How to publish an Android .aar file to Artifactory

How to publish in my maven local repository an existing aar with gradle?

How to get .AAR file from gradle dependency?

How to reset Apache Archiva Password

How to prevent password expiration in apache Archiva

How can I add docstrings to android maven-publish .aar files in build.gradle.kts?

How to download a aar file from a private gitlab repo via gradle

How to exclude a file from an .AAR Android library archive with gradle

Gradle: how to include dependencies from repositories to output aar file

Publish .aar file with javadocs attached on artifactory repo

Gradle: How do I publish a custom file artifact?

How do I publish file created by zip task in gradle

Apache Archiva Maven releated

How to migrate Apache Archiva repository from old server to new server

archiva extra file not visible

How to get packagename of aar file?

How to convert an .aar file into a .jar

How to exclude files from aar with Gradle dynamically?

How to set name of AAR output from Gradle

Easiest way to publish AAR

Publish WAR file to Maven Repo using Gradle

Can gradle resolve dependencies from just a Android .aar file?

Why gradle 3.2.1 generate unnecessary/duplicated empty folder in aar file?

How to publish a WCF against a publish settings file?

How to publish a WAR file to maven (Nexus) repository with Jenkins via Gradle task

How to publish proguard JAR as Maven Artifact using Gradle Publish Plugin

How to remove .aar file form Android Studio

How to build Flutter project with Android aar file?