gradle 7 compatibility fast way

This commit is contained in:
Primakov Alexandr Alexandrovich 2023-08-08 16:21:48 +03:00
parent 3825b3f1e0
commit 8b148a3a0d

View File

@ -28,7 +28,7 @@ def safeExtGet(prop, fallback) {
} }
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'maven' apply plugin: 'maven-publish'
buildscript { buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone. // The Android Gradle plugin is only required when opening the android folder stand-alone.
@ -47,7 +47,7 @@ buildscript {
} }
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'maven' apply plugin: 'maven-publish'
android { android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
@ -113,47 +113,47 @@ def configureReactNativePom(def pom) {
} }
} }
afterEvaluate { project -> // afterEvaluate { project ->
// some Gradle build hooks ref: // // some Gradle build hooks ref:
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html // // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
task androidJavadoc(type: Javadoc) { // task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs // source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath) // classpath += files(android.bootClasspath)
classpath += files(project.getConfigurations().getByName('compile').asList()) // classpath += files(project.getConfigurations().getByName('compile').asList())
include '**/*.java' // include '**/*.java'
} // }
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { // task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc' // classifier = 'javadoc'
from androidJavadoc.destinationDir // from androidJavadoc.destinationDir
} // }
task androidSourcesJar(type: Jar) { // task androidSourcesJar(type: Jar) {
classifier = 'sources' // classifier = 'sources'
from android.sourceSets.main.java.srcDirs // from android.sourceSets.main.java.srcDirs
include '**/*.java' // include '**/*.java'
} // }
android.libraryVariants.all { variant -> // android.libraryVariants.all { variant ->
def name = variant.name.capitalize() // def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get() // def javaCompileTask = variant.javaCompileProvider.get()
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) { // task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir // from javaCompileTask.destinationDir
} // }
} // }
artifacts { // artifacts {
archives androidSourcesJar // archives androidSourcesJar
archives androidJavadocJar // archives androidJavadocJar
} // }
task installArchives(type: Upload) { // task installArchives(type: Upload) {
configuration = configurations.archives // configuration = configurations.archives
repositories.mavenDeployer { // repositories.mavenDeployer {
// Deploy to react-native-event-bridge/maven, ready to publish to npm // // Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://${projectDir}/../android/maven" // repository url: "file://${projectDir}/../android/maven"
configureReactNativePom pom // configureReactNativePom pom
} // }
} // }
} // }