From e605a1477e99c87441e498206edd1bd3a88b62ee Mon Sep 17 00:00:00 2001 From: Matt Creaser Date: Mon, 9 Sep 2024 17:04:37 -0300 Subject: [PATCH] chore(apollo): Fix publishing errors with apollo-appsync (#2913) --- apollo/apollo-appsync/build.gradle.kts | 1 + build.gradle.kts | 112 +++++++++++++------------ configuration/publishing.gradle | 2 +- 3 files changed, 59 insertions(+), 56 deletions(-) diff --git a/apollo/apollo-appsync/build.gradle.kts b/apollo/apollo-appsync/build.gradle.kts index af5052eb3..2d827ce4d 100644 --- a/apollo/apollo-appsync/build.gradle.kts +++ b/apollo/apollo-appsync/build.gradle.kts @@ -23,6 +23,7 @@ plugins { java { withSourcesJar() + withJavadocJar() } kotlin { diff --git a/build.gradle.kts b/build.gradle.kts index 1d62e9bc4..8365cd05a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -119,9 +119,7 @@ subprojects { } @Suppress("ExpiredTargetSdkVersion") -fun Project.configureAndroid() = pluginManager.withPlugin("com.android.library") { - val sdkVersionName = findProperty("VERSION_NAME") ?: rootProject.findProperty("VERSION_NAME") - +fun Project.configureAndroid() { if (hasProperty("signingKeyId")) { println("Getting signing info from protected source.") extra["signing.keyId"] = findProperty("signingKeyId") @@ -129,72 +127,76 @@ fun Project.configureAndroid() = pluginManager.withPlugin("com.android.library") extra["signing.inMemoryKey"] = findProperty("signingInMemoryKey") } - configure { - buildToolsVersion = "30.0.3" - compileSdk = 34 + pluginManager.withPlugin("com.android.library") { + val sdkVersionName = findProperty("VERSION_NAME") ?: rootProject.findProperty("VERSION_NAME") - buildFeatures { - // Allow specifying custom buildConfig fields - buildConfig = true - } + configure { + buildToolsVersion = "30.0.3" + compileSdk = 34 - defaultConfig { - minSdk = 24 - targetSdk = 30 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - testInstrumentationRunnerArguments += "clearPackageData" to "true" - consumerProguardFiles += rootProject.file("configuration/consumer-rules.pro") - - testOptions { - animationsDisabled = true - unitTests { - isIncludeAndroidResources = true - } + buildFeatures { + // Allow specifying custom buildConfig fields + buildConfig = true } - buildConfigField("String", "VERSION_NAME", "\"$sdkVersionName\"") - } + defaultConfig { + minSdk = 24 + targetSdk = 30 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunnerArguments += "clearPackageData" to "true" + consumerProguardFiles += rootProject.file("configuration/consumer-rules.pro") + + testOptions { + animationsDisabled = true + unitTests { + isIncludeAndroidResources = true + } + } - lint { - warningsAsErrors = true - abortOnError = true - enable += listOf("UnusedResources", "NewerVersionAvailable") - } + buildConfigField("String", "VERSION_NAME", "\"$sdkVersionName\"") + } - compileOptions { - isCoreLibraryDesugaringEnabled = true - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } + lint { + warningsAsErrors = true + abortOnError = true + enable += listOf("UnusedResources", "NewerVersionAvailable") + } - tasks.withType().configureEach { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() + compileOptions { + isCoreLibraryDesugaringEnabled = true + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } - } - // Needed when running integration tests. The oauth2 library uses relies on two - // dependencies (Apache's httpcore and httpclient), both of which include - // META-INF/DEPENDENCIES. Tried a couple other options to no avail. - packagingOptions { - resources.excludes.addAll( - listOf( - "META-INF/DEPENDENCIES", - "META-INF/LICENSE.md", - "META-INF/LICENSE-notice.md" + tasks.withType().configureEach { + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + } + } + + // Needed when running integration tests. The oauth2 library uses relies on two + // dependencies (Apache's httpcore and httpclient), both of which include + // META-INF/DEPENDENCIES. Tried a couple other options to no avail. + packagingOptions { + resources.excludes.addAll( + listOf( + "META-INF/DEPENDENCIES", + "META-INF/LICENSE.md", + "META-INF/LICENSE-notice.md" + ) ) - ) - } + } - publishing { - singleVariant("release") { - withSourcesJar() + publishing { + singleVariant("release") { + withSourcesJar() + } } } - } - dependencies { - add("coreLibraryDesugaring", libs.android.desugartools) + dependencies { + add("coreLibraryDesugaring", libs.android.desugartools) + } } } diff --git a/configuration/publishing.gradle b/configuration/publishing.gradle index 1828e939a..707caf636 100644 --- a/configuration/publishing.gradle +++ b/configuration/publishing.gradle @@ -57,7 +57,7 @@ afterEvaluate { project -> from(components.named("release").get()) } project.pluginManager.withPlugin("java-library") { - from(components["java"]) + from(components.named("java").get()) } pom {