Skip to content

Commit 53bae8e

Browse files
dulmandakhSetito
authored andcommitted
use maven-publish plugin (facebook#31611)
Summary: Gradle has been showing below warning for a while, and this PR fixes the warning using maven-publish plugin, thus taking us one step closer to Gradle 7.x. > The maven plugin has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the maven-publish plugin instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.9/userguide/upgrading_version_5.html#legacy_publication_system_is_deprecated_and_replaced_with_the_publish_plugins Configured maven-publish plugin according to https://developer.android.com/studio/build/maven-publish-plugin, also added **installArchives** task for backwards compatibility. ## Changelog [Internal] [Changed] - use maven-publish plugin to build and publish Android artifact Pull Request resolved: facebook#31611 Test Plan: ./gradlew :ReactAndroid:installArchives will create **android** directory for local maven repository with **react-native** package. Reviewed By: yungsters Differential Revision: D28802435 Pulled By: ShikaSD fbshipit-source-id: 7bc7650a700e1a61213c5ec238bcb24fdca954db
1 parent 4fca6f9 commit 53bae8e

File tree

2 files changed

+56
-90
lines changed

2 files changed

+56
-90
lines changed

ReactAndroid/build.gradle

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
plugins {
99
id("com.android.library")
1010
id("com.facebook.react.codegen")
11-
id("maven")
11+
id("maven-publish")
1212
id("de.undercouch.download")
1313
}
1414

@@ -18,6 +18,7 @@ import de.undercouch.gradle.tasks.download.Download
1818
import org.apache.tools.ant.taskdefs.condition.Os
1919
import org.apache.tools.ant.filters.ReplaceTokens
2020

21+
def AAR_OUTPUT_URL = "file://${projectDir}/../android"
2122
// We download various C++ open-source dependencies into downloads.
2223
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
2324
// After that we build native code from src/main/jni with module path pointing at third-party-ndk.
@@ -425,6 +426,10 @@ task extractJNIFiles {
425426
}
426427
}
427428

429+
task installArchives {
430+
dependsOn("publishReleasePublicationToNpmRepository")
431+
}
432+
428433
android {
429434
compileSdkVersion 30
430435
ndkVersion ANDROID_NDK_VERSION
@@ -516,8 +521,6 @@ dependencies {
516521
androidTestImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")
517522
}
518523

519-
apply(from: "release.gradle")
520-
521524
react {
522525
// TODO: The library name is chosen for parity with Fabric components & iOS
523526
// This should be changed to a more generic name, e.g. `ReactCoreSpec`.
@@ -526,3 +529,53 @@ react {
526529
reactNativeRootDir = file("$projectDir/..")
527530
useJavaGenerator = System.getenv("USE_CODEGEN_JAVAPOET") ?: false
528531
}
532+
533+
afterEvaluate {
534+
publishing {
535+
publications {
536+
release(MavenPublication) {
537+
// Applies the component for the release build variant.
538+
from components.release
539+
540+
// You can then customize attributes of the publication as shown below.
541+
artifactId = POM_ARTIFACT_ID
542+
groupId = GROUP
543+
version = VERSION_NAME
544+
545+
pom {
546+
name = POM_NAME
547+
description = "A framework for building native apps with React"
548+
url = "https://github.com/facebook/react-native"
549+
550+
developers {
551+
developer {
552+
id = "facebook"
553+
name = "Facebook"
554+
}
555+
}
556+
557+
licenses {
558+
license {
559+
name = "MIT License"
560+
url = "https://github.com/facebook/react-native/blob/master/LICENSE"
561+
distribution = "repo"
562+
}
563+
}
564+
565+
scm {
566+
url = "https://github.com/facebook/react-native.git"
567+
connection = "scm:git:https://github.com/facebook/react-native.git"
568+
developerConnection = "scm:git:[email protected]:facebook/react-native.git"
569+
}
570+
}
571+
}
572+
}
573+
574+
repositories {
575+
maven {
576+
name = "npm"
577+
url = AAR_OUTPUT_URL
578+
}
579+
}
580+
}
581+
}

ReactAndroid/release.gradle

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)