Skip to content

Commit

Permalink
Updates build.gradle using fix posted in issue futurepress#115
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsharp authored May 4, 2023
1 parent eff62a4 commit b56b5a9
Showing 1 changed file with 75 additions and 58 deletions.
133 changes: 75 additions & 58 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle

def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 28

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
Expand All @@ -38,8 +26,27 @@ buildscript {
}
}

apply plugin: 'com.android.library'
apply plugin: 'maven'
plugins {
id('com.android.library')
id('maven-publish')
}

def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 28

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

//apply plugin: 'com.android.library'
//apply plugin: 'maven'



//apply plugin: 'com.android.library'
//apply plugin: 'maven'

android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
Expand Down Expand Up @@ -105,47 +112,57 @@ def configureReactNativePom(def pom) {
}
}

afterEvaluate { project ->
// some Gradle build hooks ref:
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
classpath += files(project.getConfigurations().getByName('compile').asList())
include '**/*.java'
}

task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}

android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()

task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir
}
}

artifacts {
archives androidSourcesJar
archives androidJavadocJar
}

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
}
}
}
//afterEvaluate { project ->
// // some Gradle build hooks ref:
// // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
// task androidJavadoc(type: Javadoc) {
// source = android.sourceSets.main.java.srcDirs
// classpath += files(android.bootClasspath)
// project.getConfigurations().getByName('implementation').setCanBeResolved(true)
// classpath += files(project.getConfigurations().getByName('implementation').asList())
// include '**/*.java'
// }
//
// task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
// classifier = 'javadoc'
// from androidJavadoc.destinationDir
// }
//
// task androidSourcesJar(type: Jar) {
// classifier = 'sources'
// from android.sourceSets.main.java.srcDirs
// include '**/*.java'
// }
//
// android.libraryVariants.all { variant ->
// def name = variant.name.capitalize()
// def javaCompileTask = variant.javaCompileProvider.get()
//
// task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
// from javaCompileTask.destinationDir
// }
// }
//
// artifacts {
// archives androidSourcesJar
// archives androidJavadocJar
// }
//
// 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
//// }
//
// repositories {
// maven {
// url = "file://${projectDir}/../android/maven"
// configureReactNativePom pom
// }
// }
// }
//
//
//}

0 comments on commit b56b5a9

Please sign in to comment.