Skip to content

Commit 1d7a29f

Browse files
committed
Refactor tasks so they applied to all subprojects
1 parent ddfd461 commit 1d7a29f

File tree

7 files changed

+49
-239
lines changed

7 files changed

+49
-239
lines changed

build.gradle.kts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,54 @@ subprojects {
2626
jcenter()
2727
}
2828

29+
30+
tasks {
31+
32+
val copyReadMe by registering(Copy::class) {
33+
from(rootProject.file("README.md"))
34+
into(file("$buildDir/node_module"))
35+
}
36+
37+
val copyPackageJson by registering(Copy::class) {
38+
from(file("package.json"))
39+
into(file("$buildDir/node_module"))
40+
}
41+
42+
val copyJS by registering {
43+
doLast {
44+
val from = File("$buildDir/classes/kotlin/js/main/${project.name}.js")
45+
val into = File("$buildDir/node_module/${project.name}.js")
46+
into.createNewFile()
47+
into.writeText(from.readText()
48+
.replace("require('firebase-", "require('@gitlive/firebase-")
49+
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
50+
)
51+
}
52+
}
53+
54+
val copySourceMap by registering(Copy::class) {
55+
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
56+
into(file("$buildDir/node_module"))
57+
}
58+
59+
val publishToNpm by registering(Exec::class) {
60+
doFirst {
61+
if(!File("$buildDir/node_module").exists()) {
62+
mkdir("$buildDir/node_module")
63+
}
64+
}
65+
66+
val buildTask = project.tasks.names.find{
67+
it.equals("build")
68+
}
69+
70+
dependsOn(buildTask, copyPackageJson, copyJS, copySourceMap, copyReadMe)
71+
workingDir("$buildDir/node_module")
72+
//commandLine("npm", "publish")
73+
commandLine("ls")
74+
}
75+
}
76+
2977
// tasks.withType<KotlinCompile<*>> {
3078
// kotlinOptions.freeCompilerArgs += listOf(
3179
// "-Xuse-experimental=kotlin.Experimental",
@@ -50,5 +98,6 @@ subprojects {
5098
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.4")
5199
}
52100
}
101+
53102
}
54103

firebase-app/build.gradle.kts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.apache.tools.ant.taskdefs.condition.Os
6-
75
plugins {
86
id("com.android.library")
97
kotlin("multiplatform")
@@ -94,41 +92,3 @@ kotlin {
9492
}
9593
}
9694
}
97-
98-
tasks {
99-
val copyPackageJson by registering(Copy::class) {
100-
from(file("package.json"))
101-
into(file("$buildDir/node_module"))
102-
}
103-
104-
val copyJS by registering {
105-
doLast {
106-
val from = File("$buildDir/classes/kotlin/js/main/${project.name}.js")
107-
val into = File("$buildDir/node_module/${project.name}.js")
108-
into.createNewFile()
109-
into.writeText(from.readText()
110-
.replace("require('firebase-", "require('@gitlive/firebase-")
111-
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
112-
)
113-
}
114-
}
115-
116-
val copySourceMap by registering(Copy::class) {
117-
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
118-
into(file("$buildDir/node_module"))
119-
}
120-
121-
val publishToNpm by registering(Exec::class) {
122-
doFirst {
123-
mkdir("$buildDir/node_module")
124-
}
125-
126-
dependsOn(copyPackageJson, copyJS, copySourceMap)
127-
workingDir("$buildDir/node_module")
128-
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
129-
commandLine("cmd", "/c", "npm publish --registry http://localhost:4873")
130-
} else {
131-
commandLine("npm", "publish", "--registry http://localhost:4873")
132-
}
133-
}
134-
}

firebase-auth/build.gradle.kts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.apache.tools.ant.taskdefs.condition.Os
21

32
plugins {
43
id("com.android.library")
@@ -85,42 +84,3 @@ kotlin {
8584
}
8685
}
8786
}
88-
89-
tasks {
90-
val copyPackageJson by registering(Copy::class) {
91-
from(file("package.json"))
92-
into(file("$buildDir/node_module"))
93-
}
94-
95-
val copyJS by registering {
96-
doLast {
97-
val from = File("$buildDir/classes/kotlin/js/main/${project.name}.js")
98-
val into = File("$buildDir/node_module/${project.name}.js")
99-
into.createNewFile()
100-
into.writeText(from.readText()
101-
.replace("require('firebase-", "require('@gitlive/firebase-")
102-
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
103-
)
104-
}
105-
}
106-
107-
108-
val copySourceMap by registering(Copy::class) {
109-
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
110-
into(file("$buildDir/node_module"))
111-
}
112-
113-
val publishToNpm by registering(Exec::class) {
114-
doFirst {
115-
mkdir("$buildDir/node_module")
116-
}
117-
118-
dependsOn(copyPackageJson, copyJS, copySourceMap)
119-
workingDir("$buildDir/node_module")
120-
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
121-
commandLine("cmd", "/c", "npm publish --registry http://localhost:4873")
122-
} else {
123-
commandLine("npm", "publish", "--registry http://localhost:4873")
124-
}
125-
}
126-
}

firebase-common/build.gradle.kts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.apache.tools.ant.taskdefs.condition.Os
65

76
plugins {
87
id("com.android.library")
@@ -114,42 +113,3 @@ kotlin {
114113
}
115114
}
116115
}
117-
118-
tasks {
119-
val copyPackageJson by registering(Copy::class) {
120-
from(file("package.json"))
121-
into(file("$buildDir/node_module"))
122-
}
123-
124-
val copyJS by registering {
125-
doLast {
126-
val from = File("$buildDir/classes/kotlin/js/main/${project.name}.js")
127-
val into = File("$buildDir/node_module/${project.name}.js")
128-
into.createNewFile()
129-
into.writeText(from.readText()
130-
.replace("require('firebase-", "require('@gitlive/firebase-")
131-
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
132-
)
133-
}
134-
}
135-
136-
137-
val copySourceMap by registering(Copy::class) {
138-
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
139-
into(file("$buildDir/node_module"))
140-
}
141-
142-
val publishToNpm by registering(Exec::class) {
143-
doFirst {
144-
mkdir("$buildDir/node_module")
145-
}
146-
147-
dependsOn(copyPackageJson, copyJS, copySourceMap)
148-
workingDir("$buildDir/node_module")
149-
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
150-
commandLine("cmd", "/c", "npm publish --registry http://localhost:4873")
151-
} else {
152-
commandLine("npm", "publish", "--registry http://localhost:4873")
153-
}
154-
}
155-
}

firebase-database/build.gradle.kts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.apache.tools.ant.taskdefs.condition.Os
21

32
plugins {
43
id("com.android.library")
@@ -86,42 +85,3 @@ kotlin {
8685
}
8786
}
8887
}
89-
90-
tasks {
91-
val copyPackageJson by registering(Copy::class) {
92-
from(file("package.json"))
93-
into(file("$buildDir/node_module"))
94-
}
95-
96-
val copyJS by registering {
97-
doLast {
98-
val from = File("$buildDir/classes/kotlin/js/main/${project.name}.js")
99-
val into = File("$buildDir/node_module/${project.name}.js")
100-
into.createNewFile()
101-
into.writeText(from.readText()
102-
.replace("require('firebase-", "require('@gitlive/firebase-")
103-
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
104-
)
105-
}
106-
}
107-
108-
109-
val copySourceMap by registering(Copy::class) {
110-
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
111-
into(file("$buildDir/node_module"))
112-
}
113-
114-
val publishToNpm by registering(Exec::class) {
115-
doFirst {
116-
mkdir("$buildDir/node_module")
117-
}
118-
119-
dependsOn(copyPackageJson, copyJS, copySourceMap)
120-
workingDir("$buildDir/node_module")
121-
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
122-
commandLine("cmd", "/c", "npm publish --registry http://localhost:4873")
123-
} else {
124-
commandLine("npm", "publish", "--registry http://localhost:4873")
125-
}
126-
}
127-
}

firebase-firestore/build.gradle.kts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.apache.tools.ant.taskdefs.condition.Os
21

32
plugins {
43
id("com.android.library")
@@ -86,42 +85,3 @@ kotlin {
8685
}
8786
}
8887
}
89-
90-
tasks {
91-
val copyPackageJson by registering(Copy::class) {
92-
from(file("package.json"))
93-
into(file("$buildDir/node_module"))
94-
}
95-
96-
val copyJS by registering {
97-
doLast {
98-
val from = File("$buildDir/classes/kotlin/js/main/${project.name}.js")
99-
val into = File("$buildDir/node_module/${project.name}.js")
100-
into.createNewFile()
101-
into.writeText(from.readText()
102-
.replace("require('firebase-", "require('@gitlive/firebase-")
103-
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
104-
)
105-
}
106-
}
107-
108-
109-
val copySourceMap by registering(Copy::class) {
110-
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
111-
into(file("$buildDir/node_module"))
112-
}
113-
114-
val publishToNpm by registering(Exec::class) {
115-
doFirst {
116-
mkdir("$buildDir/node_module")
117-
}
118-
119-
dependsOn(copyPackageJson, copyJS, copySourceMap)
120-
workingDir("$buildDir/node_module")
121-
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
122-
commandLine("cmd", "/c", "npm publish --registry http://localhost:4873")
123-
} else {
124-
commandLine("npm", "publish", "--registry http://localhost:4873")
125-
}
126-
}
127-
}

firebase-functions/build.gradle.kts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.apache.tools.ant.taskdefs.condition.Os
21

32
plugins {
43
id("com.android.library")
@@ -86,41 +85,3 @@ kotlin {
8685
}
8786
}
8887
}
89-
90-
tasks {
91-
val copyPackageJson by registering(Copy::class) {
92-
from(file("package.json"))
93-
into(file("$buildDir/node_module"))
94-
}
95-
96-
val copyJS by registering {
97-
doLast {
98-
val from = File("$buildDir/classes/kotlin/js/main/${project.name}.js")
99-
val into = File("$buildDir/node_module/${project.name}.js")
100-
into.createNewFile()
101-
into.writeText(from.readText()
102-
.replace("require('firebase-", "require('@gitlive/firebase-")
103-
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
104-
)
105-
}
106-
}
107-
108-
val copySourceMap by registering(Copy::class) {
109-
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
110-
into(file("$buildDir/node_module"))
111-
}
112-
113-
val publishToNpm by registering(Exec::class) {
114-
doFirst {
115-
mkdir("$buildDir/node_module")
116-
}
117-
118-
dependsOn(copyPackageJson, copyJS, copySourceMap)
119-
workingDir("$buildDir/node_module")
120-
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
121-
commandLine("cmd", "/c", "npm publish --registry http://localhost:4873")
122-
} else {
123-
commandLine("npm", "publish", "--registry http://localhost:4873")
124-
}
125-
}
126-
}

0 commit comments

Comments
 (0)