I need to publish a library on Sonatype, on our own server at the company. I've used maven-publish plugin with the following implementation.
apply plugin: 'maven-publish'
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
}
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId GROUP_ID
artifactId ARTIFACT_ID
version VERSION_NAME
from components.release
artifact androidSourcesJar
pom {
name = ARTIFACT_ID
description = DESCRIPTION
url = 'library url'
licenses {
license {
name = 'License'
url = 'license url'
}
}
developers {
developer {
id = 'dev id'
name = 'dev name'
email = 'dev mail'
}
}
scm {
connection = 'url.git'
developerConnection = 'url.git'
url = 'url.git'
}
}
}
}
repositories {
maven {
url MAVEN_REPOSITORY_URL
credentials {
username = USER_NAME
password = PASSWORD
}
}
}
}
}
The library got published successfully, but when I use it I have to specify that I need the aar as following.
implementation 'com.companyname.android:library-name:1.0.0@aar'
what should I do to use it without the aar specification? like the following.
implementation 'com.companyname.android:library-name:1.0.0'
So Gradle could find the aar file and add it to the external libraries.