Skip to content

Commit 52662ad

Browse files
committed
Continue refactoring: make better publishing, move implicit options to the build parameters
1 parent 1cfb434 commit 52662ad

File tree

22 files changed

+280
-242
lines changed

22 files changed

+280
-242
lines changed

api-examples/getting-started/build.gradle.kts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ dependencies {
1818

1919
kotlinPublications {
2020
publication {
21-
publicationName = "example-getting-started"
22-
artifactId = "kotlin-jupyter-example-getting-started"
23-
description = "Basic API usage example"
24-
packageName = artifactId
25-
publishToSonatype = false
21+
publicationName.set("example-getting-started")
22+
description.set("Basic API usage example")
23+
publishToSonatype.set(false)
2624
}
2725
}

build-tools/build-plugin/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
13
plugins {
24
id("build.plugins.versions")
35
`kotlin-dsl`
@@ -20,6 +22,12 @@ sourceSets {
2022
}
2123
}
2224

25+
tasks.withType<KotlinCompile> {
26+
kotlinOptions {
27+
freeCompilerArgs = freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn")
28+
}
29+
}
30+
2331
gradlePlugin {
2432
plugins {
2533
create("dependencies") {

build-tools/build-plugin/src/build/options.kt renamed to build-tools/build-plugin/src/build/KernelBuildExtension.kt

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,74 @@ import org.gradle.api.Task
55
import org.gradle.kotlin.dsl.extra
66
import org.gradle.kotlin.dsl.invoke
77
import org.gradle.kotlin.dsl.provideDelegate
8-
import java.nio.file.Path
9-
import java.nio.file.Paths
8+
import java.io.File
109

11-
open class KernelBuildExtension(
12-
private val project: Project
10+
class KernelBuildExtension(
11+
val project: Project
1312
) {
14-
var packageName = "kotlin-jupyter-kernel"
13+
var kotlinLanguageLevel by project.prop<String>()
14+
var stableKotlinLanguageLevel by project.prop<String>()
15+
var jvmTarget by project.prop<String>()
1516

16-
val versionFileName = "VERSION"
17-
val rootPath: Path = project.rootDir.toPath()
17+
var githubRepoUser by project.prop<String>()
18+
var githubRepoName by project.prop<String>()
19+
var projectRepoUrl by project.prop<String>()
20+
var docsRepo by project.prop<String>()
21+
var librariesRepoUrl by project.prop<String>()
22+
var librariesRepoUserAndName by project.prop<String>()
1823

19-
val isLocalBuild = project.getFlag("build.isLocal")
24+
var skipReadmeCheck by project.prop<Boolean>()
2025

21-
val artifactsDir: Path = run {
22-
val artifactsPathStr = project.rootProject.findProperty("artifactsPath") as? String ?: "artifacts"
23-
val artifactsDir = rootPath.resolve(artifactsPathStr)
26+
val buildCounter by project.prop("build.counter", "100500")
27+
val buildNumber by project.prop("build.number", "")
28+
29+
val devCounter by project.prop<String?>("build.devCounter")
30+
31+
var libName by project.prop<String>("jupyter.lib.name")
32+
var libParamName by project.prop<String>("jupyter.lib.param.name")
33+
var libParamValue by project.prop<String>("jupyter.lib.param.value")
34+
35+
var prGithubUser by project.prop<String>("jupyter.github.user")
36+
var prGithubToken by project.prop<String>("jupyter.github.token")
37+
38+
var baseVersion by project.prop<String>()
39+
var isLocalBuild by project.prop<Boolean>("build.isLocal")
40+
41+
var jvmTargetForSnippets by project.prop<String?>()
42+
43+
var packageName: String = project.rootProject.name
44+
45+
var versionFileName = "VERSION"
46+
47+
val artifactsDir: File = run {
48+
val artifactsPath by project.prop(default = "artifacts")
49+
val artifactsDir = project.rootDir.resolve(artifactsPath)
2450

2551
if (isLocalBuild) {
2652
project.delete(artifactsDir)
2753
}
2854
return@run artifactsDir
2955
}
3056

31-
val localPublicationsRepo: Path = artifactsDir.resolve("maven")
32-
33-
val baseVersion = project.prop<String>("baseVersion")
34-
35-
val pythonVersion: String = project.detectVersion(baseVersion, artifactsDir, versionFileName)
57+
val pythonVersion: String = project.detectVersion(this)
3658

3759
val mavenVersion = pythonVersion.toMavenVersion()
3860

39-
val readmePath: Path = rootPath.resolve("docs").resolve("README.md")
61+
val readmePath: File = project.rootDir.resolve("docs").resolve("README.md")
4062

41-
private val installPath = project.prop<String?>("installPath")
63+
private val installPath = project.typedProperty<String?>("installPath")
4264

4365
val librariesPath = "libraries"
44-
val librariesPropertiesPath: Path = rootPath.resolve(librariesPath).resolve(".properties")
66+
val librariesPropertiesPath: File = project.rootDir.resolve(librariesPath).resolve(".properties")
4567

46-
val installPathLocal: Path = if (installPath != null) Paths.get(installPath)
47-
else Paths.get(System.getProperty("user.home").toString(), ".ipython", "kernels", "kotlin")
68+
val installPathLocal: File = if (installPath != null) project.file(installPath)
69+
else project.file(System.getProperty("user.home").toString()).resolve(".ipython/kernels/kotlin")
4870

4971
val resourcesDir = "resources"
50-
val distribBuildPath: Path = rootPath.resolve("build").resolve("distrib-build")
51-
val logosPath = getSubDir(rootPath, resourcesDir, "logos")
52-
val nbExtensionPath = getSubDir(rootPath, resourcesDir, "notebook-extension")
53-
val distributionPath: Path by project.extra(rootPath.resolve("distrib"))
72+
val distribBuildPath: File = project.rootDir.resolve("build").resolve("distrib-build")
73+
val logosPath = project.rootDir.resolve(resourcesDir).resolve("logos")
74+
val nbExtensionPath = project.rootDir.resolve(resourcesDir).resolve("notebook-extension")
75+
val distributionPath: File by project.extra(project.rootDir.resolve("distrib"))
5476
val jarsPath = "jars"
5577
val configDir = "config"
5678

@@ -75,22 +97,15 @@ open class KernelBuildExtension(
7597
val runKernelDir = "run_kotlin_kernel"
7698
val setupPy = "setup.py"
7799

78-
val copyRunKernelPy: Task
79-
get() = project.tasks.getByName("copyRunKernelPy")
80-
val prepareDistributionDir: Task
81-
get() = project.tasks.getByName("prepareDistributionDir")
82-
val cleanInstallDirDistrib: Task
83-
get() = project.tasks.getByName("cleanInstallDirDistrib")
84-
85100
val isOnProtectedBranch: Boolean
86101
get() = project.extra["isOnProtectedBranch"] as Boolean
87102

88-
val distribUtilsPath: Path = rootPath.resolve("distrib-util")
89-
val distribUtilRequirementsPath: Path = distribUtilsPath.resolve("requirements-common.txt")
90-
val distribUtilRequirementsHintsRemPath: Path =
103+
private val distribUtilsPath: File = project.rootDir.resolve("distrib-util")
104+
val distribUtilRequirementsPath: File = distribUtilsPath.resolve("requirements-common.txt")
105+
val distribUtilRequirementsHintsRemPath: File =
91106
distribUtilsPath.resolve("requirements-hints-remover.txt")
92107
val removeTypeHints = true
93-
val typeHintsRemover: Path = distribUtilsPath.resolve("remove_type_hints.py")
108+
val typeHintsRemover: File = distribUtilsPath.resolve("remove_type_hints.py")
94109

95110
val condaTaskSpecs by lazy {
96111
val condaUserStable = project.stringPropOrEmpty("condaUserStable")
@@ -143,6 +158,6 @@ open class KernelBuildExtension(
143158
}
144159

145160
companion object {
146-
const val NAME = "kernelBuild"
161+
const val NAME = "options"
147162
}
148163
}

build-tools/build-plugin/src/build/distribution.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package build
22

3-
import org.gradle.api.Project
43
import org.gradle.api.tasks.Exec
54
import org.gradle.api.tasks.InputFile
6-
import org.gradle.kotlin.dsl.getByType
7-
import java.nio.file.Path
5+
import java.io.File
86

97
open class TaskSpec(
108
var taskName: String = ""
@@ -26,17 +24,17 @@ class UploadTaskSpecs <T : TaskSpec>(
2624

2725
private fun taskName(type: String) = repoName + "Upload" + type
2826

29-
fun createTasks(project: Project, taskCreationAction: (T) -> Unit) {
30-
val opts = project.extensions.getByType<KernelBuildExtension>()
31-
if (opts.isOnProtectedBranch) {
27+
fun createTasks(options: KernelBuildExtension, taskCreationAction: (T) -> Unit) {
28+
val project = options.project
29+
if (options.isOnProtectedBranch) {
3230
taskCreationAction(stable)
3331
}
3432
taskCreationAction(dev)
3533

3634
project.task(taskName("Protected")) {
37-
dependsOn(opts.cleanInstallDirDistrib)
35+
dependsOn(project.tasks.getByName(CLEAN_INSTALL_DIR_DISTRIB_TASK))
3836
group = taskGroup
39-
if (opts.isOnProtectedBranch) {
37+
if (options.isOnProtectedBranch) {
4038
dependsOn(dev.taskName)
4139
}
4240
}
@@ -61,7 +59,7 @@ class PyPiTaskSpec(
6159

6260
abstract class PipInstallReq : Exec() {
6361
@get:InputFile
64-
var requirementsFile: Path? = null
62+
var requirementsFile: File? = null
6563
set(value) {
6664
commandLine("python", "-m", "pip", "install", "-r", value)
6765
field = value

0 commit comments

Comments
 (0)