From 3561378a9b889d5f92a32054219d3f8595aa3bdc Mon Sep 17 00:00:00 2001 From: Anatoly Pristensky Date: Tue, 9 Jan 2024 15:25:38 +0100 Subject: [PATCH] [CI] Migrate Maven-Release to ESRP-Release task (#1022) * Migrate AppCenterReactNativeShared to MavenPublication * Update URL * Correct numeration --------- Co-authored-by: Dmitriy Kirakosyan --- .../android/build.gradle | 117 ++++++++---------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../android/version.gradle | 5 + scripts/put-maven-secrets-gradle.sh | 7 +- 4 files changed, 60 insertions(+), 71 deletions(-) create mode 100755 AppCenterReactNativeShared/android/version.gradle diff --git a/AppCenterReactNativeShared/android/build.gradle b/AppCenterReactNativeShared/android/build.gradle index 15ffb59e0..dddb7951f 100644 --- a/AppCenterReactNativeShared/android/build.gradle +++ b/AppCenterReactNativeShared/android/build.gradle @@ -5,89 +5,74 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.1.4' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:4.2.1' } } +repositories { + google() + mavenCentral() +} + apply from: 'publish.gradle' +apply from: 'version.gradle' -apply plugin: 'com.android.library' apply plugin: 'maven-publish' apply plugin: 'signing' -apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'com.android.library' def wasSigned = false -allprojects { - repositories { - google() - mavenCentral() - jcenter { - content { - // https://youtrack.jetbrains.com/issue/IDEA-261387 - includeModule("org.jetbrains.trove4j", "trove4j") - } +def ext = rootProject.ext + +// Setup signing values. +ext."signing.keyId" = ext.mavenSigningKeyId +ext."signing.secretKeyRingFile" = ext.mavenSecretKeyPath +ext."signing.password" = ext.mavenPublicKeyPassword + +android { + compileSdkVersion 29 + buildToolsVersion '29.0.2' + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 29 + versionCode 66 + versionName '5.0.1' + group groupId + version versionName + buildConfigField 'String', "SDK_NAME", "\"appcenter.react-native\"" + buildConfigField 'String', 'VERSION_NAME', "\"${ext.versionName}\"" + + ndk { + abiFilters "armeabi-v7a", "x86" } + consumerProguardFiles 'proguard-rules.pro' } +} - def ext = rootProject.ext - - // Setup signing values. - ext."signing.keyId" = ext.mavenSigningKeyId - ext."signing.secretKeyRingFile" = ext.mavenSecretKeyPath - ext."signing.password" = ext.mavenPublicKeyPassword - - android { - compileSdkVersion 29 - buildToolsVersion '29.0.2' - - defaultConfig { - minSdkVersion 21 - targetSdkVersion 29 - versionCode 66 - versionName '5.0.1' - group groupId - version versionName - buildConfigField 'String', "SDK_NAME", "\"appcenter.react-native\"" - - ndk { - abiFilters "armeabi-v7a", "x86" - } - consumerProguardFiles 'proguard-rules.pro' - } +task sourcesJar(type: Jar) { + afterEvaluate { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' } +} - task sourcesJar(type: Jar) { - afterEvaluate { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' +publishing { + repositories { + maven { + url = uri("${System.env.BUILD_DIR}") } } - - afterEvaluate { - uploadArchives { - repositories.mavenDeployer { - beforeDeployment { MavenDeployment deployment -> - // workaround to prevent the script from failing because of double uploading of pom files - // related issue: https://github.com/gradle/gradle/issues/3003 - if (!wasSigned) { - signing.signPom(deployment) - wasSigned = true - } - } - - repository(url: ext.mavenRepoUrl) { - authentication(userName: ext.mavenUser, password: ext.mavenKey) - } + afterEvaluate { project -> + publications { + maven(MavenPublication) { + from components.release - pom.project { + artifact sourcesJar - // Set base information about assemble. + pom { packaging = 'aar' name = project.name description = sdkDescription @@ -135,6 +120,6 @@ artifacts { } signing { - required { gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives -} + required { gradle.taskGraph.hasTask("publish") } + sign publishing.publications +} \ No newline at end of file diff --git a/AppCenterReactNativeShared/android/gradle/wrapper/gradle-wrapper.properties b/AppCenterReactNativeShared/android/gradle/wrapper/gradle-wrapper.properties index 84337ad35..9fe8d05db 100644 --- a/AppCenterReactNativeShared/android/gradle/wrapper/gradle-wrapper.properties +++ b/AppCenterReactNativeShared/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip diff --git a/AppCenterReactNativeShared/android/version.gradle b/AppCenterReactNativeShared/android/version.gradle new file mode 100755 index 000000000..ea088da32 --- /dev/null +++ b/AppCenterReactNativeShared/android/version.gradle @@ -0,0 +1,5 @@ +// Bintray constants + +ext { + versionName = '5.0.1' +} \ No newline at end of file diff --git a/scripts/put-maven-secrets-gradle.sh b/scripts/put-maven-secrets-gradle.sh index 63f901fc4..a5ee0004a 100755 --- a/scripts/put-maven-secrets-gradle.sh +++ b/scripts/put-maven-secrets-gradle.sh @@ -2,8 +2,7 @@ cat >> AppCenterReactNativeShared/android/local.properties << EOL maven.user=${1:-$MAVEN_USER} maven.key=${2:-$MAVEN_KEY} -maven.repoUrl=${3:-$MAVEN_REPO} -maven.signingKeyId=${4:-$GDP_SIGNING_KEY_ID} -maven.secretKeyPath=${5:-$GDP_KEY_SECRET_PATH} -maven.publicKeyPassword=${6:-$GDP_KEY_PASSWORD} +maven.signingKeyId=${3:-$GDP_SIGNING_KEY_ID} +maven.secretKeyPath=${4:-$GDP_KEY_SECRET_PATH} +maven.publicKeyPassword=${5:-$GDP_KEY_PASSWORD} EOL