|
| 1 | +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary |
| 2 | + |
1 | 3 | apply plugin: 'com.android.library' |
2 | 4 | apply plugin: 'org.jetbrains.kotlin.android' |
3 | 5 | apply plugin: 'kotlin-parcelize' |
| 6 | +apply plugin: 'com.vanniktech.maven.publish' |
| 7 | +apply plugin: 'org.jetbrains.dokka-javadoc' |
4 | 8 |
|
5 | 9 | //Detailed information about advantages of Java toolchain https://developer.android.com/build/jdks#toolchain |
6 | 10 | java { |
@@ -85,6 +89,40 @@ android { |
85 | 89 | } |
86 | 90 | } |
87 | 91 |
|
| 92 | +group = 'com.glia' |
| 93 | + |
| 94 | +mavenPublishing { |
| 95 | + def isSnapshot = findProperty("snapshot")?.toString() == "yes" |
| 96 | + //Plugin automatically publishes snapshot to the Maven Central when the version name ends with `-SNAPSHOT` |
| 97 | + //To publish snapshot release simply call the publishing command with gradle property `-Psnapshot=yes` |
| 98 | + //for example `./gradlew androidSdk:publishMavenPublicationToMavenLocal -Psnapshot=yes` |
| 99 | + |
| 100 | + version = isSnapshot ? widgetsVersionName + "-SNAPSHOT" : widgetsVersionName |
| 101 | + coordinates(group, 'android-widgets', version) |
| 102 | + configure(new AndroidSingleVariantLibrary('release', true, false/* enable javadoc generation */)) |
| 103 | + |
| 104 | + pom { |
| 105 | + excludeOptionalDependencies(it) |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | +//Excludes the Firebase Messaging from the .aar dependencies to avoid requiring integrators to include them in their applications. |
| 110 | +def excludeOptionalDependencies(mavenPom) { |
| 111 | + mavenPom.withXml { |
| 112 | + final pomNode = asNode() |
| 113 | + pomNode.dependencyManagement.dependencies.'*'.findAll() { |
| 114 | + it.artifactId.text() == 'firebase-bom' |
| 115 | + }.each() { |
| 116 | + it.parent().remove(it) |
| 117 | + } |
| 118 | + pomNode.dependencies.'*'.findAll() { |
| 119 | + it.artifactId.text() == 'firebase-messaging' |
| 120 | + }.each() { |
| 121 | + it.parent().remove(it) |
| 122 | + } |
| 123 | + } |
| 124 | +} |
| 125 | + |
88 | 126 | tasks.register('publishSnapshotPublicationToMavenLocal', GradleBuild) { |
89 | 127 | description = 'Publishes the Snapshot publication to Maven Local with -SNAPSHOT suffix' |
90 | 128 | group = 'publishing' |
@@ -112,6 +150,25 @@ tasks.register("publishCoreSdkToLocalMaven") { |
112 | 150 | } |
113 | 151 | } |
114 | 152 |
|
| 153 | +// For generating Javadoc jar using Dokka |
| 154 | +tasks.register('dokkaJavadocJar', Jar.class) { |
| 155 | + dependsOn(dokkaGeneratePublicationJavadoc) |
| 156 | + from(dokkaGeneratePublicationJavadoc) |
| 157 | + archiveClassifier.set("javadoc") |
| 158 | +} |
| 159 | + |
| 160 | +// CRITICAL: Ensure the Dokka JAR is included in the published artifacts. |
| 161 | +afterEvaluate { |
| 162 | + publishing { |
| 163 | + publications { |
| 164 | + maven(MavenPublication) { |
| 165 | + // CRITICAL: Add the generated Javadoc jar to the published artifacts. |
| 166 | + artifact dokkaJavadocJar |
| 167 | + } |
| 168 | + } |
| 169 | + } |
| 170 | +} |
| 171 | + |
115 | 172 | apply from: "${rootProject.projectDir}/scripts/direct-core.gradle" |
116 | 173 |
|
117 | 174 | dependencies { |
@@ -176,5 +233,3 @@ configurations.configureEach { |
176 | 233 | // Always check remote repo for changing modules (SNAPSHOTs) |
177 | 234 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds' |
178 | 235 | } |
179 | | - |
180 | | -apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" |
|
0 commit comments