I want to publish my SDK in maven with $ ./gradlew uploadArchives
I had this project structure:
MyProject
|_ SDK
|_ src
|_ main
|_ java
|_ java files
|_ build.gradle
|_ gradle
|_ gradle-publish.gradle
I used following code (gradle-publish.gradle
) that works as expected:
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
uploadArchives {
repositories {
mavenDeployer {
/* ... */
}
}
}
artifacts {
archives sourcesJar
archives androidJavadocsJar
}
Now I splitted main module to 2: SDK
and new_module
so my project structure looks like:
MyProject
|_ SDK
|_ src
|_ main
|_ java
|_ java files "com.app"
|_ build.gradle
|_ new_module
|_ src
|_ main
|_ java
|_ java files "com.app.mod"
|_ build.gradle
|_ gradle
|_ gradle-publish.gradle
However no matter what I do, I always get only SDK
sources and not new_module
a.e. com.app
should be merged with com.app.mod
I tried to play with sourceSets
but it looks like it works inside main module SDK
and not under root project:
sourceSets {
main{
java {
srcDirs(
"src/main/java",
"../new_module/src/main/java"
)
}
}
and:
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
Any ideas, tips?
Edit
I added
sourceSets {
main{
java {
srcDirs("src/main/java",
"${root_dir}/new_module/src/main/java"
)
}
}
}
However on maven I see all have sources but classes.jar
contains only app
.class
files
Add custom sourceSet
under android
section of your SDK
build.gradle
:
android{
//...
sourceSets {
main{
java {
srcDirs "$rootDir/new_module/src/main/java/"
}
}
}
}
You don't need include "src/main/java"
- its already included
Also you don't need bind new_module
into your dependancies, new_module
will be a part of your SDK
module
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
Check this link it's intended for distribution through Jcenter, follow the steps mentioned in the link for each of your submodules.
And make sure all your submodules are published to the same remote with a common GROUP_ID.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With