Skip to content

Commit

Permalink
Merge pull request #916 from DataDog/nogorodnikov/rumm-2095/support-n…
Browse files Browse the repository at this point in the history
…ew-agp-publishing-model

RUMM-2095: Support new AGP publishing model
  • Loading branch information
0xnm authored Apr 29, 2022
2 parents e160fdd + d7ea8d1 commit b86ff41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
26 changes: 11 additions & 15 deletions buildSrc/src/main/kotlin/com/datadog/gradle/config/MavenConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

package com.datadog.gradle.config

import com.android.build.gradle.LibraryExtension
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.findByType
import org.gradle.plugins.signing.SigningExtension

Expand All @@ -18,23 +18,21 @@ object MavenConfig {
const val PUBLICATION = "release"
}

@Suppress("UnstableApiUsage")
fun Project.publishingConfig(projectDescription: String) {
val projectName = name

@Suppress("UnstableApiUsage")
tasks.register("generateJavadocJar", Jar::class.java) {
group = "publishing"
dependsOn("dokkaJavadoc")
archiveClassifier.convention("javadoc")
from("${buildDir.canonicalPath}/reports/javadoc")
val androidExtension =
extensions.findByType(LibraryExtension::class.java)
if (androidExtension == null) {
logger.error("Missing android library extension for $projectName")
return
}

@Suppress("UnstableApiUsage")
tasks.register("generateSourcesJar", Jar::class.java) {
group = "publishing"
archiveClassifier.convention("sources")
from("${projectDir.canonicalPath}/src/main")
androidExtension.publishing {
singleVariant(MavenConfig.PUBLICATION) {
withSourcesJar()
withJavadocJar()
}
}

afterEvaluate {
Expand All @@ -49,8 +47,6 @@ fun Project.publishingConfig(projectDescription: String) {

publications.create(MavenConfig.PUBLICATION, MavenPublication::class.java) {
from(components.getByName("release"))
artifact(tasks.findByName("generateSourcesJar"))
artifact(tasks.findByName("generateJavadocJar"))

groupId = MavenConfig.GROUP_ID
artifactId = projectName
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
#
org.gradle.jvmargs=-Xmx2560m -XX:MaxPermSize=512m
android.useAndroidX=true
android.disableAutomaticComponentCreation=true
# Leave the next line blank for CI

0 comments on commit b86ff41

Please sign in to comment.