I'm trying to convert an existing app to an AAR.
I managed to turn it into an AAR, autogenerate the pom file and upload it in a maven repository. The generated pom file correctly include the relative dependencies, like for example:
implementation "joda-time:joda-time:2.10.1"
get converted in:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.1</version>
<scope>runtime</scope>
</dependency>
My problem is that the app also use local libraries/modules, like this:
implementation project(':CameraModule')
implementation project(':VideoTranscoderModule')
when the pom file is generated this libraries are included in it with the following format:
<dependency>
<groupId>myapp-android</groupId>
<artifactId>CameraModule</artifactId>
<version>unspecified</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>myapp-android</groupId>
<artifactId>VideoTranscoderModule</artifactId>
<version>unspecified</version>
<scope>compile</scope>
</dependency>
this dependencies are not resolved when trying to include the AAR in another app
implementation ('com.myapp.sdk:thesdk:1.1.2') {
transitive = true
}
And I ger the following build error:
> Could not find myapp-android:CameraModule:unspecified.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/myapp-android/CameraModule/unspecified/CameraModule-unspecified.pom
- https://repo.maven.apache.org/maven2/myapp-android/CameraModule/unspecified/CameraModule-unspecified.pom
- http://localhost:8081/repository/maven-releases/myapp-android/CameraModule/unspecified/CameraModule-unspecified.pom
How can I solve this?
This is my publishing gradle script:
apply plugin: 'maven-publish'
apply plugin: 'signing'
tasks.register("sourceJar", Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
}
project.ext["signing.keyId"] = "ABCDE123"
project.ext["signing.secretKeyRingFile"] = "aar-signing.key"
project.ext["signing.password"] = "ThePasswordHere123"
afterEvaluate {
publishing {
publications {
releaseAar(MavenPublication) {
from components.debug
artifact sourceJar
groupId = "com.myapp.sdk"
artifactId = "thesdk"
version = "1.1.2"
pom {
name = 'My App SDK'
description = 'Testing'
url = 'https://example.com/'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = 'Something'
name = 'Myname Here'
email = 'email@example.com'
}
}
}
}
}
repositories {
maven {
name = "mynexusrepo"
credentials {
username = "username123"
password = "123password"
}
url = uri("http://localhost:8081/repository/maven-releases/")
allowInsecureProtocol = true
}
}
}
signing {
sign(publishing.publications)
}
}