Skip to content

Commit

Permalink
Support multiple dependencies in publishing configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiddot committed Mar 9, 2022
1 parent 4aba1cb commit ec57255
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.json.JSONObject

plugins {
id("com.github.node-gradle.node") version "3.1.1"
id("com.android.library") apply false
Expand All @@ -18,6 +20,10 @@ project.ext.set("compileSdkVersion", defaultCompileSdkVersion)
project.ext.set("minSdkVersion", defaultMinSdkVersion)
project.ext.set("targetSdkVersion", defaultTargetSdkVersion)

// Fetch dependencies versions from package.json
val packageJson = JSONObject(File("$rootDir/package.json").readText())
val packageDevDependencies = packageJson.optJSONObject("devDependencies")

subprojects {
apply(plugin = "maven-publish")

Expand Down Expand Up @@ -59,14 +65,17 @@ subprojects {
}

afterEvaluate {
project(":react-native-get-random-values").afterEvaluate {
afterEvaluate {
configure<PublishingExtension> {
publications {
create<MavenPublication>("S3") {
val packageVersion = packageDevDependencies.optString(project.name)
println("Publishing configuration:\n\tartifactId=\"${project.name}\"\n\tversion=\"$packageVersion\"")

from(components.get("release"))
groupId = "org.wordpress-mobile"
artifactId = "react-native-get-random-values"
version = "1.4.0"
artifactId = project.name
version = packageVersion

versionMapping {
allVariants {
Expand Down

0 comments on commit ec57255

Please sign in to comment.