Closed bill-dai closed 2 years ago
I manually change maven to maven-publish on line 23 and line 42, but ran into another error:
FAILURE: Build failed with an exception.
Where: Build file '/Users/username/Workspace/appname/node_modules/react-native-ultimate-config/android/build.gradle' line: 112
What went wrong: A problem occurred configuring project ':react-native-ultimate-config'. Configuration with name 'compile' not found.
This is the line causing the issue: classpath += files(project.getConfigurations().getByName('compile').asList())
In Gradle 7, the configurations compile, testCompile, runtime and testRuntime have been removed in favor of implementation, testImplementation, runtimeOnly and testRuntimeOnly.
hey, thanks for the report!
I'll try to look at this problem but I don't have a lot of capacity at the moment.
If you or somebody can open an PR - it would be great!
thanks!
@bill-dai could you please share an example project where the problem reproduced? what version of react native do you use by the way?
yeah, I found it's actually my issue. I opened my React Native 6.5.1 Android project in Android Studio and it asked me if I wanted to upgrade to Gradle 7, and I clicked yes and this caused the error. So I'm reverting to the 4.2.1 (6.8) Gradle Plugin right now.
cool, still good to know upcoming issues :)
I encountered the same problem. I had to revert back to 4.2.2 (6.9.1) Gradle Plugin for now.
Hi @maxkomarychev! Since react-native: 0.67.3 requires Gradle version 7+ now - it's a huge blocker for anyone who uses the latest RN version
Any suggestions?
can somebody try this fork https://github.com/maxkomarychev/react-native-ultimate-config/pull/79 and confirm if it works?
@tr3v3r I can, but what with installArchives that mentioned in pr description?
@maxkomarychev Hi! any thoughts?
can somebody try this fork #79 and confirm if it works?
I tested it and it's working fine. Before the application did not build on android and now the build is being done without problems.
@tr3v3r hey there, I am the guy who opened the #79 PR, The installArchives section is not really relevant to react-native or npm packages, it would be relevant if @maxkomarychev uploads the package externally to a maven/gradle repo, but that is the extent of my knowledge on maven or gradle repos for that matter. The fix works, guaranteed, I use it in a couple of projects already, I mentioned the installArchives problematics in the PR because I do not know what the intention of it was, and technically speaking, my PR is "not complete" because I didn't adjust that part of the lib, so I mentioned it hoping @maxkomarychev would give me a clue about what was meant there. My fix simply imports the correct maven plugins as intended with gradle 7+, and given that fact that this lib is installed using npm
, no further maven setups are really needed, but that's for the author of this lib to decide.
@samermurad Hi! Thanks for explaining! I'm gonna get back this library to my project patched with your pr until it won't be merged
@samermurad @vagnerlandio I'm in the same spot. Can you advise how to add to yarn from PR 79? I tried:
yarn add maxkomarychev/react-native-ultimate-config#79/head
which is the 'usual' syntax for adding from a PR, but it's throwing an error.
@JeremyBradshaw7 You can just use patch-package library with this patch
diff --git a/node_modules/react-native-ultimate-config/android/build.gradle b/node_modules/react-native-ultimate-config/android/build.gradle
index dcccb07..cac1277 100644
--- a/node_modules/react-native-ultimate-config/android/build.gradle
+++ b/node_modules/react-native-ultimate-config/android/build.gradle
@@ -20,7 +20,7 @@ def safeExtGet(prop, fallback) {
}
apply plugin: 'com.android.library'
-apply plugin: 'maven'
+apply plugin: 'maven-publish'
buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
@@ -39,7 +39,7 @@ buildscript {
}
apply plugin: 'com.android.library'
-apply plugin: 'maven'
+apply plugin: 'maven-publish'
android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
@@ -109,8 +109,10 @@ afterEvaluate { project ->
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
- classpath += files(project.getConfigurations().getByName('compile').asList())
+ project.getConfigurations().implementation.setCanBeResolved(true)
+ classpath += files(project.getConfigurations().getByName('implementation').asList())
include '**/*.java'
+
}
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
@@ -140,10 +142,21 @@ afterEvaluate { project ->
task installArchives(type: Upload) {
configuration = configurations.archives
- repositories.mavenDeployer {
- // Deploy to react-native-event-bridge/maven, ready to publish to npm
- repository url: "file://${projectDir}/../android/maven"
- configureReactNativePom pom
+ // Honestly I have no idea maven works, it looks like the new solution should look somewhat like
+ // so, but the pom is no longer available as a global variable under this setup
+ publishing {
+ repositories {
+ maven {
+ url "file://${projectDir}/../android/maven"
+// configureReactNativePom pom
+ }
+ }
}
+// This no longer works in
+// repositories.mavenDeployer {
+// // Deploy to react-native-event-bridge/maven, ready to publish to npm
+// repository url: "file://${projectDir}/../android/maven"
+// configureReactNativePom pom
+// }
}
}
\ No newline at end of file
I have published changes from #79 as version 4.0.0.
Please try it out. I'm going to close this issue. Thank you all for participation!
Upgraded to 3.4.1 today, but ran into another error
Build file '/Users/username/Workspace/appname/node_modules/react-native-ultimate-config/android/build.gradle' line: 23
According to the official doc here, maven-publish plugin should be used instead.
https://docs.gradle.org/7.0/userguide/upgrading_version_6.html?_ga=2.13318143.933978241.1630988644-1794747336.1630988644#removal_of_the_legacy_maven_plugin