My android project structure (MyApp is a module of Android Studio project):
MyApp
-
external / mylib.jar
-
src/
-
res/
…
build.gradle
I firstly have an external jar (mylib.jar), I want to upload it to my local maven repo, my gradle build looks like this:
configurations {
externalJar
}
artifacts {
externalJar file: file('external/mylib.jar')
artifact = 'exernalLib'
version = '1.1.0'
}
uploadExternalJar {
repositories {
mavenDeployer {
repository(url: "file://${System.properties['user.home']}/.m2/repository")
}
}
}
It works!
Then, I would also like to upload my project’s jar artifact to local maven repo. I added the following code:
group = 'com.my.app'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${System.properties['user.home']}/.m2/repository")
pom.project {
version
'1.2.1'
artifactId
'MyApp'
packaging 'jar'
}
}
}
}
when I run ./gradlew build , both tasks are executed, but when I check MyApp-1.2.1.jar in local maven, its content is overrode by external lib jar. I mean MyApp-1.2.1.jar is not uploaded to maven repo, external lib is uploaded to maven repo twice with the 2nd uploaded jar renamed to MyApp-1.2.1.jar.
I am not sure what I did wrong. But what is the correct way to upload both external jar & my project jar to local maven repo?
I am using Gradle 1.10