diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 747b9b1..700b25d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build the sample project and upload artifacts if possible +name: Build and test projects on: push: @@ -12,6 +12,25 @@ on: jobs: + sdk-build: + runs-on: ubuntu-latest + if: > + github.event_name != 'workflow_dispatch' + env: + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=2g -Dkotlin.daemon.jvm.options=-Xmx1536m" + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: '17.x' + java-package: jdk + distribution: 'temurin' + cache: 'gradle' + - name: Check sdk publications + run: ./scripts/verify-publications.bash sdk + - name: Check sdk-mock publications + run: ./scripts/verify-publications.bash sdkMock + build-and-upload: runs-on: ubuntu-latest if: > @@ -46,8 +65,6 @@ jobs: --url 'https://deploygate.com/api/users/${{ secrets.SHARED_DEPLOYGATE_APP_OWNER_NAME_FOR_PUBLIC_REPO }}/apps' | \ jq -r '"\(.results.package_name) \(.results.distribution.url)"' done < <(find ./sample/build/outputs/bundle -name "*.aab") - - name: Check javadocs - run: ./gradlew sdk:generateJavadocForReleasePublication sdkMock:generateJavadocForReleasePublication distribute-stable: runs-on: ubuntu-latest diff --git a/build.gradle b/build.gradle index 2af0534..e348f4f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,36 +1,10 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -ext { - // sdk/java/com/deploygate/sdk/HostAppTest.java needs to be changed for a new release - releaseVersion = '4.7.1' -} - -buildscript { - repositories { - mavenCentral() - google() - gradlePluginPortal() - } - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - classpath 'com.project.starter:easylauncher:5.0.1' - } -} -allprojects { - repositories { - mavenCentral() - google() - } +plugins { + id("com.deploygate.plugins.sdk") apply false + id("com.deploygate.plugins.sample-app") apply false } task clean(type: Delete) { delete rootProject.buildDir } - -task verifyReleaseVersion() { - doLast { - if (project.ext.releaseVersion != System.getenv("RELEASE_VERSION")) { - throw new GradleException("${project.ext.releaseVersion} does not equal to ${System.getenv("RELEASE_VERSION")}") - } - } -} diff --git a/gradle.properties b/gradle.properties index 2d8d1e4..3a20c71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ -android.useAndroidX=true \ No newline at end of file +android.useAndroidX=true +android.disableAutomaticComponentCreation=true diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts new file mode 100644 index 0000000..4ccfacd --- /dev/null +++ b/plugins/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` apply false +} + +tasks.register("clean", Delete::class) { + delete(rootProject.buildDir) +} diff --git a/plugins/library/build.gradle.kts b/plugins/library/build.gradle.kts new file mode 100644 index 0000000..3e6d861 --- /dev/null +++ b/plugins/library/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22") + implementation("com.android.tools.build:gradle:7.4.2") +} + +gradlePlugin { + plugins { + create("sdk") { + id = "com.deploygate.plugins.sdk" + implementationClass = "com.deploygate.plugins.SdkPlugin" + } + } +} diff --git a/plugins/library/src/main/java/com/deploygate/plugins/MavenPublishPlugin.kt b/plugins/library/src/main/java/com/deploygate/plugins/MavenPublishPlugin.kt new file mode 100644 index 0000000..aa51c8c --- /dev/null +++ b/plugins/library/src/main/java/com/deploygate/plugins/MavenPublishPlugin.kt @@ -0,0 +1,162 @@ +package com.deploygate.plugins + +import com.deploygate.plugins.ext.internalApiLibraryExtension +import com.deploygate.plugins.ext.publishingExtension +import com.deploygate.plugins.ext.sdkExtension +import com.deploygate.plugins.ext.signingExtension +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.artifacts.repositories.PasswordCredentials +import org.gradle.api.publish.PublicationContainer +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.Exec +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.register +import org.gradle.plugins.signing.SigningExtension +import java.util.Locale + +class MavenPublishPlugin : Plugin { + companion object { + private val RELEASE_VERSION_REGEX = "^\\d+\\.\\d+\\.\\d+\$".toRegex() + } + + override fun apply(target: Project) { + target.apply(plugin = "maven-publish") + target.apply(plugin = "signing") + + val artifactVersion = target.version as String + + val repositoryUsername = target.findProperty("NEXUS_USERNAME") as? String + val repositoryPassword = target.findProperty("NEXUS_PASSWORD") as? String + val signingKey = target.findProperty("signingKey") as? String + val signingPassword = target.findProperty("signingPassword") as? String + + val isRelease = artifactVersion.matches(RELEASE_VERSION_REGEX) + + target.internalApiLibraryExtension.libraryVariants.configureEach { + val variant = this + + target.tasks.register("verifyBytecodeVersion${variant.name.capitalize(Locale.ROOT)}") + .configure { + dependsOn(variant.assembleProvider) + + commandLine( + target.rootProject.file("scripts/verify-bytecode-version"), + "--aar", + variant.packageLibraryProvider.flatMap { it.archiveFile }.get(), + "--java", + SdkPlugin.JAVA_VERSION.toString() + ) + } + } + + target.publishingExtension.configurePublishingExtension( + target = target, + artifactVersion = artifactVersion, + isRelease = isRelease, + repositoryUsername = repositoryUsername, + repositoryPassword = repositoryPassword, + ) + target.signingExtension.configureSigningExtension( + isSigningRequired = isRelease, + signingKey = signingKey, + signingPassword = signingPassword, + publications = target.extensions.getByType().publications, + ) + + target.gradle.taskGraph.whenReady { + with(target.signingExtension) { + isRequired = isRequired && hasTask("publishReleasePublicationToMavenRepository") + } + } + } + + private fun PublishingExtension.configurePublishingExtension( + target: Project, + artifactVersion: String, + isRelease: Boolean, + repositoryUsername: String?, + repositoryPassword: String?, + ) { + repositories { + maven { + setUrl( + if (isRelease) { + "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + } else { + "https://oss.sonatype.org/content/repositories/snapshots/" + } + ) + + credentials(PasswordCredentials::class.java) { + username = repositoryUsername + password = repositoryPassword + } + } + } + + + publications { + create("release") { + // This block would be evaluated before components.getByName("release") was created + + groupId = "com.deploygate" + version = artifactVersion + + pom { + name.set(target.sdkExtension.displayName) + description.set(target.sdkExtension.description) + url.set("https://github.com/DeployGate/deploygate-android-sdk") + + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + + developers { + developer { + id.set("deploygate") + name.set("DeployGate") + } + } + + scm { + url.set("https://github.com/DeployGate/deploygate-android-sdk") + } + } + } + } + + target.afterEvaluate { + publications { + // Configure some values after AGP has been configured + named("release") { + from(components.getByName("release")) + artifactId = sdkExtension.artifactId.get() + } + } + } + } + + + private fun SigningExtension.configureSigningExtension( + isSigningRequired: Boolean, + signingKey: String?, + signingPassword: String?, + publications: PublicationContainer, + ) { + isRequired = isSigningRequired + useInMemoryPgpKeys(signingKey, signingPassword) + + publications.configureEach { + sign(this) + } + } +} \ No newline at end of file diff --git a/plugins/library/src/main/java/com/deploygate/plugins/SdkPlugin.kt b/plugins/library/src/main/java/com/deploygate/plugins/SdkPlugin.kt new file mode 100644 index 0000000..2fb1764 --- /dev/null +++ b/plugins/library/src/main/java/com/deploygate/plugins/SdkPlugin.kt @@ -0,0 +1,131 @@ +package com.deploygate.plugins + +import com.android.build.api.dsl.LibraryExtension +import com.deploygate.plugins.dsl.SdkExtension +import com.deploygate.plugins.ext.libraryExtension +import org.gradle.api.GradleException +import org.gradle.api.JavaVersion +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.dependencies + +class SdkPlugin : Plugin { + companion object { + /** + * sdk/java/com/deploygate/sdk/HostAppTest.java needs to be changed for a new release + */ + private const val ARTIFACT_VERSION = "4.7.1" + + val JAVA_VERSION = JavaVersion.VERSION_1_7 + } + + override fun apply(target: Project) { + target.version = ARTIFACT_VERSION + + target.extensions.create("sdk") + + target.apply(plugin = "com.android.library") + target.apply() + + target.libraryExtension.configureLibraryExtension( + artifactVersion = target.version as String, + ) + + target.tasks.register("verifyReleaseVersion") { + doLast { + if (target.version != System.getenv("RELEASE_VERSION")) { + throw GradleException("${target.version} does not equal to ${System.getenv("RELEASE_VERSION")}") + } + } + } + + target.dependencies { + add("testImplementation", "androidx.test:runner:1.5.2") + add("testImplementation", "androidx.test.ext:junit:1.1.5") + add("testImplementation", "org.robolectric:robolectric:4.10.3") + add("testImplementation", "androidx.test:rules:1.5.0") + add("testImplementation", "com.google.truth:truth:1.0") + } + + } + + fun LibraryExtension.configureLibraryExtension( + artifactVersion: String, + ) { + compileSdk = 33 + + defaultConfig { + minSdk = 14 + targetSdk = 33 + + // A map of isSupporting> + val features = linkedMapOf( + "UPDATE_MESSAGE_OF_BUILD" to true, + "SERIALIZED_EXCEPTION" to true, + "LOGCAT_BUNDLE" to true, + "STREAMED_LOGCAT" to true, + "DEVICE_CAPTURE" to true, + ) + + var flags = 0 + + features.entries.forEachIndexed { i, e -> + val (feature, isSupporting) = e + + buildConfigField("int", feature, "1 << $i") + + if (isSupporting) { + flags = flags or 1.shl(i) + } + } + + addManifestPlaceholders( + mapOf( + "featureFlags" to flags, + "sdkVersion" to "4", + "sdkArtifactVersion" to artifactVersion, + ) + ) + } + + buildTypes { + release { + isMinifyEnabled = false + } + } + + compileOptions { + sourceCompatibility(JAVA_VERSION) + targetCompatibility(JAVA_VERSION) + } + + testOptions { + unitTests { + isIncludeAndroidResources = true + + all { + it.jvmArgs( + "-Xmx1g", + ) + } + } + } + + buildFeatures { + buildConfig = true + } + + lint { + abortOnError = false + } + + publishing { + singleVariant("release") { + withJavadocJar() + withSourcesJar() + } + } + } +} \ No newline at end of file diff --git a/plugins/library/src/main/java/com/deploygate/plugins/dsl/SdkExtension.kt b/plugins/library/src/main/java/com/deploygate/plugins/dsl/SdkExtension.kt new file mode 100644 index 0000000..20877ca --- /dev/null +++ b/plugins/library/src/main/java/com/deploygate/plugins/dsl/SdkExtension.kt @@ -0,0 +1,9 @@ +package com.deploygate.plugins.dsl + +import org.gradle.api.provider.Property + +interface SdkExtension { + val artifactId: Property + val displayName: Property + val description: Property +} \ No newline at end of file diff --git a/plugins/library/src/main/java/com/deploygate/plugins/ext/ProjectExt.kt b/plugins/library/src/main/java/com/deploygate/plugins/ext/ProjectExt.kt new file mode 100644 index 0000000..3d935ae --- /dev/null +++ b/plugins/library/src/main/java/com/deploygate/plugins/ext/ProjectExt.kt @@ -0,0 +1,23 @@ +package com.deploygate.plugins.ext + +import com.android.build.api.dsl.LibraryExtension +import com.deploygate.plugins.dsl.SdkExtension +import org.gradle.api.Project +import org.gradle.api.publish.PublishingExtension +import org.gradle.kotlin.dsl.getByType +import org.gradle.plugins.signing.SigningExtension + +val Project.sdkExtension: SdkExtension + get() = extensions.getByType() + +val Project.libraryExtension: LibraryExtension + get() = extensions.getByType() + +val Project.signingExtension: SigningExtension + get() = extensions.getByType() + +val Project.publishingExtension: PublishingExtension + get() = extensions.getByType() + +val Project.internalApiLibraryExtension: com.android.build.gradle.LibraryExtension + get() = extensions.getByType() \ No newline at end of file diff --git a/plugins/sample/build.gradle.kts b/plugins/sample/build.gradle.kts new file mode 100644 index 0000000..de857d7 --- /dev/null +++ b/plugins/sample/build.gradle.kts @@ -0,0 +1,18 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22") + implementation("com.android.tools.build:gradle:7.4.2") + implementation("com.project.starter:easylauncher:5.0.1") +} + +gradlePlugin { + plugins { + create("sample") { + id = "com.deploygate.plugins.sample-app" + implementationClass = "com.deploygate.plugins.SampleAppPlugin" + } + } +} diff --git a/plugins/sample/src/main/java/com/deploygate/plugins/SampleAppPlugin.kt b/plugins/sample/src/main/java/com/deploygate/plugins/SampleAppPlugin.kt new file mode 100644 index 0000000..f4281ca --- /dev/null +++ b/plugins/sample/src/main/java/com/deploygate/plugins/SampleAppPlugin.kt @@ -0,0 +1,130 @@ +package com.deploygate.plugins + +import com.android.build.gradle.AppExtension +import com.project.starter.easylauncher.filter.ColorRibbonFilter +import com.project.starter.easylauncher.plugin.EasyLauncherExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.invoke + +class SampleAppPlugin : Plugin { + override fun apply(target: Project) { + target.apply(plugin = "com.android.application") + target.apply(plugin = "com.starter.easylauncher") + + target.extensions.findByType(AppExtension::class.java)?.configureAppExtension() + target.extensions.findByType(EasyLauncherExtension::class.java) + ?.configureEasyLauncherExtension() + } + + private fun AppExtension.configureAppExtension() { + compileSdkVersion(33) + + defaultConfig { + applicationId = "com.deploygate.sample" + minSdk = 14 + targetSdk = 33 + } + + buildTypes { + named("debug") { + applicationIdSuffix = ".debug" + } + named("release") { + minifyEnabled(true) + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-project.txt", + ) + } + create("distribute") { + debuggable(true) + matchingFallbacks += "release" + } + } + + flavorDimensions("mode") + + productFlavors { + create("devreal") { + dimension("mode") + applicationIdSuffix(".realsdk.dev") + } + create("devmock") { + dimension("mode") + applicationIdSuffix(".mocksdk.dev") + } + create("stablereal") { + dimension("mode") + applicationIdSuffix(".realsdk.stable") + } + create("stablemock") { + dimension("mode") + applicationIdSuffix(".mocksdk.stable") + } + } + + compileOptions { + sourceCompatibility(JavaVersion.VERSION_1_8) + targetCompatibility(JavaVersion.VERSION_1_8) + } + + lintOptions { + isAbortOnError = false + } + } + + private fun EasyLauncherExtension.configureEasyLauncherExtension() { + defaultFlavorNaming(true) + + productFlavors { + create("devreal") { + filters( + customRibbon( + label = "devreal", + ribbonColor = "#55E74C3C", + labelColor = "#FFFFFF", + gravity = ColorRibbonFilter.Gravity.TOPRIGHT, + ), + ) + } + create("devmock") { + filters( + customRibbon( + label = "devmock", + ribbonColor = "#556600CC", + labelColor = "#FFFFFF", + gravity = ColorRibbonFilter.Gravity.TOPRIGHT, + ), + ) + } + create("stablereal") { + enable(false) + } + create("stablemock") { + enable(false) + } + } + + buildTypes { + create("debug") { + filters( + customRibbon( + label = "debug", + ribbonColor = "#5574924", + labelColor = "#FFFFFF", + gravity = ColorRibbonFilter.Gravity.BOTTOM, + ), + ) + } + create("distribute") { + enable(false) + } + create("release") { + enable(false) + } + } + } +} \ No newline at end of file diff --git a/plugins/settings.gradle b/plugins/settings.gradle new file mode 100644 index 0000000..db68059 --- /dev/null +++ b/plugins/settings.gradle @@ -0,0 +1,19 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +include(":library") +include(":sample") diff --git a/publishing.build.gradle b/publishing.build.gradle deleted file mode 100644 index 64b53d3..0000000 --- a/publishing.build.gradle +++ /dev/null @@ -1,103 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' - -def publicationVariants = ["release"] - -def getRepositoryUsername() { - return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" -} - -def getRepositoryPassword() { - return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" -} - -def isRelease() { - return rootProject.ext.releaseVersion =~ /^\d+\.\d+\.\d+$/ -} - -android.libraryVariants.configureEach { variant -> - if (publicationVariants.contains(variant.name)) { - project.task("generateJavadocFor${variant.name.capitalize()}Publication", type: Javadoc) { - source = variant.getJavaCompileProvider().get().source - classpath = variant.getJavaCompileProvider().get().classpath + files(project.android.getBootClasspath()) - options.linkSource true - } - - project.task("generateSourcesJarFor${variant.name.capitalize()}Publication", type: Jar) { - archiveClassifier.set('sources') - from variant.sourceSets.collect { it.javaDirectories }.flatten() - } - - project.task("generateJavadocsJarFor${variant.name.capitalize()}Publication", type: Jar) { - archiveClassifier.set('javadoc') - from files(tasks.getByName("generateJavadocFor${variant.name.capitalize()}Publication")) - } - - project.tasks.findByName("verifyBytecodeVersion${variant.name.capitalize()}").dependsOn( - "generateSourcesJarFor${variant.name.capitalize()}Publication", - "generateJavadocsJarFor${variant.name.capitalize()}Publication", - "generatePomFileFor${variant.name.capitalize()}Publication" - ) - } -} - -afterEvaluate { - publishing { - repositories { - maven { - url = isRelease() ? "https://oss.sonatype.org/service/local/staging/deploy/maven2/" : "https://oss.sonatype.org/content/repositories/snapshots/" - - credentials(PasswordCredentials) { - username = getRepositoryUsername() - password = getRepositoryPassword() - } - } - } - - publications { - release(MavenPublication) { - from components.release - artifact generateSourcesJarForReleasePublication - artifact generateJavadocsJarForReleasePublication - - groupId = 'com.deploygate' - artifactId = project.ext.artifactId - version = project.version - - pom { - name = project.ext.displayName - description = project.ext.desc - url = 'https://github.com/DeployGate/deploygate-android-sdk' - licenses { - license { - name = "The Apache Software License, Version 2.0" - url = "http://www.apache.org/licenses/LICENSE-2.0.txt" - distribution = "repo" - } - } - developers { - developer { - id = "deploygate" - name = "DeployGate" - } - } - scm { - url = 'https://github.com/DeployGate/deploygate-android-sdk' - } - } - } - } - } - - signing { - required { isRelease() && gradle.taskGraph.hasTask("publishReleasePublicationToMavenRepository") } - - def signingKey = findProperty("signingKey") - def signingPassword = findProperty("signingPassword") - useInMemoryPgpKeys(signingKey, signingPassword) - publishing.publications.configureEach { publication -> - sign publication - } - } -} - diff --git a/sample/build.gradle b/sample/build.gradle index 5c82649..e42ac8b 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,90 +1,4 @@ -apply plugin: 'com.android.application' -apply plugin: 'com.starter.easylauncher' - -android { - compileSdkVersion 33 - - defaultConfig { - applicationId "com.deploygate.sample" - minSdkVersion 14 - targetSdkVersion 33 - } - - buildTypes { - debug { - applicationIdSuffix '.debug' - } - distribute { - debuggable true - matchingFallbacks = ['release'] - } - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt' - } - } - - flavorDimensions "mode" - - productFlavors { - devreal { - dimension "mode" - applicationIdSuffix ".realsdk.dev" - } - devmock { - dimension "mode" - applicationIdSuffix ".mocksdk.dev" - } - stablereal { - dimension "mode" - applicationIdSuffix ".realsdk.stable" - } - stablemock { - dimension "mode" - applicationIdSuffix ".mocksdk.stable" - } - } - - lintOptions { - abortOnError false - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -easylauncher { - defaultFlavorNaming true - - productFlavors { - devreal { - filters = customColorRibbonFilter("devreal", "#55E74C3C", "#FFFFFF", "topRight") - } - devmock { - filters = customColorRibbonFilter("devmock", "#556600CC", "#FFFFFF", "topRight") - } - stablereal { - enable false - } - stablemock { - enable false - } - } - - buildTypes { - debug { - filters = customColorRibbonFilter("debug", "#5574924", "#FFFFFF", "bottom") - } - distribute { - enable false - } - release { - enable false - } - } -} +apply plugin: 'com.deploygate.plugins.sample-app' dependencies { devrealImplementation project(':sdk') diff --git a/scripts/verify-publications.bash b/scripts/verify-publications.bash new file mode 100755 index 0000000..0440ca9 --- /dev/null +++ b/scripts/verify-publications.bash @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -euo pipefail + +die() { + echo "$*" >&2 + exit 1 +} + +readonly tmp_dir="$(mktemp -d)" + +readonly module_name="$1" + +./gradlew \ + "${module_name}:verifyBytecodeVersionRelease" \ + "${module_name}:publishReleasePublicationToMavenLocal" \ + --stacktrace + +cat "${module_name}/build/publications/release/module.json" + +readonly artifact_id="$(jq -r '.component.module' "${module_name}/build/publications/release/module.json")" +readonly version="$(jq -r '.component.version' "${module_name}/build/publications/release/module.json")" + +cat< "${tmp_dir}/expected.txt" +${artifact_id}-${version}-javadoc.jar +${artifact_id}-${version}-sources.jar +${artifact_id}-${version}.aar +EOF + +jq -r '[.variants[] | .files[] | .name] | unique | sort | .[]' \ + "${module_name}/build/publications/release/module.json" | tee "${tmp_dir}/actual.txt" + +if ! diff "${tmp_dir}/expected.txt" "${tmp_dir}/actual.txt"; then + die "Publications do or don't contain expected artifacts" +fi diff --git a/sdk.build.gradle b/sdk.build.gradle deleted file mode 100644 index b15dc8d..0000000 --- a/sdk.build.gradle +++ /dev/null @@ -1,89 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'maven-publish' - -version = rootProject.ext.releaseVersion - -android { - compileSdkVersion 33 - - defaultConfig { - minSdkVersion 14 - targetSdkVersion 33 - versionCode 1 - versionName project.version - - // A map of name to isSupporting - def features = [ - UPDATE_MESSAGE_OF_BUILD: true, - SERIALIZED_EXCEPTION: true, - LOGCAT_BUNDLE: true, - STREAMED_LOGCAT: true, - DEVICE_CAPTURE: true, - ] - - if (!(features instanceof LinkedHashMap)) { - throw new IllegalAccessException("The key order may not be kept") - } - - int flags = 0 - - features.keySet().eachWithIndex { String key, int i -> - buildConfigField("int", key, "1 << $i") - - if (features[key]) { - flags |= 1 << i - } - } - - manifestPlaceholders += [ - featureFlags: flags, - sdkVersion: "4", - sdkArtifactVersion: project.version, - ] - } - - buildTypes { - release { - minifyEnabled false - } - } - - lintOptions { - abortOnError false - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - } - - testOptions { - unitTests { - includeAndroidResources = true - } - unitTests.all { - jvmArgs "-Xmx1g" - } - } - - buildFeatures { - buildConfig = true - } -} - -dependencies { - testImplementation 'androidx.test:runner:1.5.2' - testImplementation 'androidx.test.ext:junit:1.1.5' - testImplementation 'org.robolectric:robolectric:4.10.3' - - testImplementation 'androidx.test:rules:1.5.0' - testImplementation 'com.google.truth:truth:1.0' -} - -android.libraryVariants.configureEach { variant -> - tasks.register("verifyBytecodeVersion${variant.name.capitalize()}", Exec).configure { - dependsOn "assemble${variant.name.capitalize()}" - - commandLine rootProject.file("scripts/verify-bytecode-version").path, "--aar", project.file("build/outputs/aar/${project.name}-${variant.name}.aar"), "--java", project.android.compileOptions.targetCompatibility.toString() - } -} \ No newline at end of file diff --git a/sdk/build.gradle b/sdk/build.gradle index 3bf40f5..0a273f5 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -1,4 +1,4 @@ -apply from: rootProject.file('sdk.build.gradle') +apply plugin: 'com.deploygate.plugins.sdk' android { defaultConfig { @@ -11,10 +11,8 @@ dependencies { testImplementation 'org.mockito:mockito-inline:4.4.0' } -ext { - displayName = "DeployGate SDK" - artifactId = 'sdk' - desc = 'DeployGate SDK for Android' +sdk { + displayName.set("DeployGate SDK") + artifactId.set('sdk') + description.set('DeployGate SDK for Android') } - -apply from: rootProject.file('publishing.build.gradle') \ No newline at end of file diff --git a/sdkMock/build.gradle b/sdkMock/build.gradle index f5e61e8..79be5a2 100644 --- a/sdkMock/build.gradle +++ b/sdkMock/build.gradle @@ -1,9 +1,7 @@ -apply from: rootProject.file('sdk.build.gradle') +apply plugin: 'com.deploygate.plugins.sdk' -ext { - displayName = "DeployGate SDK Mock" - artifactId = 'sdk-mock' - desc = 'Mocked dummy DeployGate SDK for Android to reduce footprint of your release version app without code modification' +sdk { + displayName.set("DeployGate SDK Mock") + artifactId.set('sdk-mock') + description.set('Mocked dummy DeployGate SDK for Android to reduce footprint of your release version app without code modification') } - -apply from: rootProject.file('publishing.build.gradle') \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index b49ce19..7578263 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,35 @@ -include ':sdk', ':sdkMock', ':sample' +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + + pluginManagement { + resolutionStrategy { + eachPlugin { + switch(requested.id.id) { + case "deploygate": + useModule("com.deploygate:gradle:${requested.version}") + break + } + } + } + } + + includeBuild("plugins") +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven { + url 'https://deploygate.github.io/maven/artifacts' + content { includeGroup "com.deploygate" } + } + } +} + +include ':sdk', ':sdkMock', ':sample' \ No newline at end of file