Skip to content

Commit d275f1d

Browse files
committed
Add library descriptors as git submodule
1 parent 4a2d043 commit d275f1d

File tree

7 files changed

+27
-12
lines changed

7 files changed

+27
-12
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libraries"]
2+
path = libraries
3+
url = https://github.com/Kotlin/kotlin-jupyter-libraries.git

docs/README-STUB.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Uninstall: `pip uninstall kotlin-jupyter-kernel`
5252
### From sources
5353

5454
```bash
55-
git clone [[repo_url]]
55+
git clone --recurse-submodules [[repo_url]]
5656
cd kotlin-jupyter
5757
./gradlew install
5858
```

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Uninstall: `pip uninstall kotlin-jupyter-kernel`
5252
### From sources
5353

5454
```bash
55-
git clone https://github.com/Kotlin/kotlin-jupyter.git
55+
git clone --recurse-submodules https://github.com/Kotlin/kotlin-jupyter.git
5656
cd kotlin-jupyter
5757
./gradlew install
5858
```

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ githubRepoName=kotlin-jupyter
2525
projectRepoUrl=https://github.com/Kotlin/kotlin-jupyter
2626
docsRepo=[email protected]:ileasile/kotlin-jupyter-docs.git
2727
pushRepoUrl=[email protected]:Kotlin/kotlin-jupyter.git
28+
librariesRepoUrl=[email protected]:Kotlin/kotlin-jupyter-libraries.git
29+
librariesRepoUserAndName=Kotlin/kotlin-jupyter-libraries
2830

2931
# Workaround for https://github.com/Kotlin/dokka/issues/1405
3032
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1024m -Xmx2048m

kotlin-jupyter-plugin/src/main/kotlin/org/jetbrains/kotlinx/jupyter/build/versionDetection.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ import org.gradle.api.Project
44
import org.gradle.kotlin.dsl.extra
55
import org.gradle.kotlin.dsl.invoke
66
import java.io.ByteArrayOutputStream
7+
import java.io.File
78
import java.nio.file.Path
89

9-
fun Project.getPropertyByCommand(propName: String, cmdArgs: Array<String>): String {
10+
fun Project.getPropertyByCommand(
11+
propName: String,
12+
cmdArgs: Array<String>,
13+
workingDir: File? = null,
14+
): String {
1015
val prop = project.findProperty(propName) as String?
1116

1217
if (prop != null) {
@@ -17,6 +22,7 @@ fun Project.getPropertyByCommand(propName: String, cmdArgs: Array<String>): Stri
1722
val result = exec {
1823
commandLine(*cmdArgs)
1924
standardOutput = outputStream
25+
workingDir?.let { this.workingDir = it }
2026
}
2127

2228
val output = outputStream.toString()

kotlin-jupyter-plugin/src/main/kotlin/org/jetbrains/kotlinx/jupyter/build/versionUpdating.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ private val Project.libParamValue get() = prop<String>("jupyter.lib.param.value"
3131
private val Project.prGithubUser get() = prop<String>("jupyter.github.user")
3232
private val Project.prGithubToken get() = prop<String>("jupyter.github.token")
3333

34-
private val Project.githubRepoOwner get() = prop<String>("githubRepoUser")
35-
private val Project.githubRepoName get() = prop<String>("githubRepoName")
36-
3734
@Serializable
3835
class NewPrData(
3936
val title: String,
@@ -89,11 +86,12 @@ fun ProjectWithInstallOptions.prepareKotlinVersionUpdateTasks() {
8986
val pushChangesTask = tasks.register("pushChanges") {
9087
dependsOn(updateLibraryParamTask)
9188

89+
val librariesDir = projectDir.resolve(librariesPath)
9290
fun execGit(vararg args: String, configure: ExecSpec.() -> Unit = {}): ExecResult {
9391
return exec {
9492
this.executable = "git"
9593
this.args = args.asList()
96-
this.workingDir = projectDir
94+
this.workingDir = librariesDir
9795

9896
configure()
9997
}
@@ -106,8 +104,13 @@ fun ProjectWithInstallOptions.prepareKotlinVersionUpdateTasks() {
106104
execGit("add", ".")
107105
execGit("commit", "-m", "[AUTO] Update library version")
108106

109-
val repoUrl = rootProject.property("pushRepoUrl") as String
110-
execGit("push", "--force", "-u", repoUrl, getCurrentBranch() + ":refs/heads/" + updateLibBranchName!!) {
107+
val repoUrl = rootProject.property("librariesRepoUrl") as String
108+
val currentBranch = getPropertyByCommand(
109+
"build.libraries.branch",
110+
arrayOf("git", "rev-parse", "--abbrev-ref", "HEAD"),
111+
librariesDir,
112+
)
113+
execGit("push", "--force", "-u", repoUrl, "$currentBranch:refs/heads/" + updateLibBranchName!!) {
111114
this.standardOutput = object : OutputStream() {
112115
override fun write(b: Int) { }
113116
}
@@ -123,6 +126,7 @@ fun ProjectWithInstallOptions.prepareKotlinVersionUpdateTasks() {
123126
doLast {
124127
val user = rootProject.prGithubUser
125128
val password = rootProject.prGithubToken
129+
val repoUserAndName = rootProject.property("librariesRepoUserAndName") as String
126130
fun githubRequest(
127131
method: Method,
128132
request: String,
@@ -141,9 +145,8 @@ fun ProjectWithInstallOptions.prepareKotlinVersionUpdateTasks() {
141145
return response
142146
}
143147

144-
val fullRepo = "${rootProject.githubRepoOwner}/${rootProject.githubRepoName}"
145148
val prResponse = githubRequest(
146-
Method.POST, "repos/$fullRepo/pulls",
149+
Method.POST, "repos/$repoUserAndName/pulls",
147150
Json.encodeToJsonElement(
148151
NewPrData(
149152
title = "Update `${rootProject.libName}` library to `${rootProject.libParamValue}`",
@@ -157,7 +160,7 @@ fun ProjectWithInstallOptions.prepareKotlinVersionUpdateTasks() {
157160

158161
val prNumber = (prResponse.jsonObject["number"] as JsonPrimitive).int
159162
githubRequest(
160-
Method.POST, "repos/$fullRepo/issues/$prNumber/labels",
163+
Method.POST, "repos/$repoUserAndName/issues/$prNumber/labels",
161164
Json.encodeToJsonElement(
162165
SetLabelsData(listOf("no-changelog", "library-descriptors"))
163166
)

libraries

Submodule libraries added at 454a2ee

0 commit comments

Comments
 (0)