Skip to content

Commit 0b36e2b

Browse files
dulmandakhtido64
authored andcommitted
use maven-publish plugin (#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: #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 c299694 commit 0b36e2b

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.
@@ -377,6 +378,10 @@ task extractJNIFiles {
377378
}
378379
}
379380

381+
task installArchives {
382+
dependsOn("publishReleasePublicationToNpmRepository")
383+
}
384+
380385
android {
381386
compileSdkVersion 30
382387
ndkVersion ANDROID_NDK_VERSION
@@ -468,8 +473,6 @@ dependencies {
468473
androidTestImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")
469474
}
470475

471-
apply(from: "release.gradle")
472-
473476
react {
474477
// TODO: The library name is chosen for parity with Fabric components & iOS
475478
// This should be changed to a more generic name, e.g. `ReactCoreSpec`.
@@ -478,3 +481,53 @@ react {
478481
reactNativeRootDir = file("$projectDir/..")
479482
useJavaGenerator = System.getenv("USE_CODEGEN_JAVAPOET") ?: false
480483
}
484+
485+
afterEvaluate {
486+
publishing {
487+
publications {
488+
release(MavenPublication) {
489+
// Applies the component for the release build variant.
490+
from components.release
491+
492+
// You can then customize attributes of the publication as shown below.
493+
artifactId = POM_ARTIFACT_ID
494+
groupId = GROUP
495+
version = VERSION_NAME
496+
497+
pom {
498+
name = POM_NAME
499+
description = "A framework for building native apps with React"
500+
url = "https://github.com/facebook/react-native"
501+
502+
developers {
503+
developer {
504+
id = "facebook"
505+
name = "Facebook"
506+
}
507+
}
508+
509+
licenses {
510+
license {
511+
name = "MIT License"
512+
url = "https://github.com/facebook/react-native/blob/master/LICENSE"
513+
distribution = "repo"
514+
}
515+
}
516+
517+
scm {
518+
url = "https://github.com/facebook/react-native.git"
519+
connection = "scm:git:https://github.com/facebook/react-native.git"
520+
developerConnection = "scm:git:[email protected]:facebook/react-native.git"
521+
}
522+
}
523+
}
524+
}
525+
526+
repositories {
527+
maven {
528+
name = "npm"
529+
url = AAR_OUTPUT_URL
530+
}
531+
}
532+
}
533+
}

ReactAndroid/release.gradle

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

0 commit comments

Comments
 (0)