Skip to content

Commit d57f335

Browse files
committed
docs build: move parameter initialization to the parent project
in order to avoid evaluationDependsOn dependency
1 parent 596ff23 commit d57f335

File tree

2 files changed

+31
-37
lines changed

2 files changed

+31
-37
lines changed

libraries/tools/kotlin-stdlib-docs/build.gradle.kts

+25-11
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,34 @@ plugins {
88
id("org.jetbrains.dokka")
99
}
1010

11-
evaluationDependsOnChildren()
11+
val isTeamcityBuild = project.hasProperty("teamcity.version")
12+
13+
// kotlin/libraries/tools/kotlin-stdlib-docs -> kotlin
14+
val kotlin_root = rootProject.file("../../../").absoluteFile.invariantSeparatorsPath
15+
val kotlin_libs by extra("$buildDir/libs")
16+
17+
val rootProperties = java.util.Properties().apply {
18+
file(kotlin_root).resolve("gradle.properties").inputStream().use { stream -> load(stream) }
19+
}
20+
val defaultSnapshotVersion: String by rootProperties
21+
22+
val githubRevision = if (isTeamcityBuild) project.property("githubRevision") else "master"
23+
val artifactsVersion by extra(if (isTeamcityBuild) project.property("deployVersion") as String else defaultSnapshotVersion)
24+
val artifactsRepo by extra(if (isTeamcityBuild) project.property("kotlinLibsRepo") as String else "$kotlin_root/build/repo")
25+
val dokka_version: String by project
26+
27+
println("# Parameters summary:")
28+
println(" isTeamcityBuild: $isTeamcityBuild")
29+
println(" dokka version: $dokka_version")
30+
println(" githubRevision: $githubRevision")
31+
println(" artifacts version: $artifactsVersion")
32+
println(" artifacts repo: $artifactsRepo")
1233

13-
fun pKotlinBig() = project("kotlin_big").ext
1434

1535
val outputDir = file(findProperty("docsBuildDir") as String? ?: "$buildDir/doc")
1636
val inputDirPrevious = file(findProperty("docsPreviousVersionsDir") as String? ?: "$outputDir/previous")
1737
val outputDirPartial = outputDir.resolve("partial")
18-
val kotlin_root: String by pKotlinBig()
19-
val kotlin_libs: String by pKotlinBig()
2038
val kotlin_native_root = file("$kotlin_root/kotlin-native").absolutePath
21-
val github_revision: String by pKotlinBig()
22-
val localRoot = kotlin_root
23-
val baseUrl = URL("https://github.com/JetBrains/kotlin/tree/$github_revision")
2439
val templatesDir = file(findProperty("templatesDir") as String? ?: "$projectDir/templates").invariantSeparatorsPath
2540

2641
val cleanDocs by tasks.registering(Delete::class) {
@@ -39,7 +54,6 @@ repositories {
3954
mavenCentral()
4055
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev")
4156
}
42-
val dokka_version: String by project
4357

4458
dependencies {
4559
dokkaPlugin(project(":plugins:dokka-samples-transformer-plugin"))
@@ -371,13 +385,13 @@ fun GradleDokkaSourceSetBuilder.perPackageOption(packageNamePrefix: String, acti
371385

372386
fun GradleDokkaSourceSetBuilder.sourceLinksFromRoot() {
373387
sourceLink {
374-
localDirectory.set(file(localRoot))
375-
remoteUrl.set(baseUrl)
388+
localDirectory.set(file(kotlin_root))
389+
remoteUrl.set(URL("https://github.com/JetBrains/kotlin/tree/$githubRevision"))
376390
remoteLineSuffix.set("#L")
377391
}
378392
}
379393

380-
gradle.projectsEvaluated {
394+
run {
381395
val versions = listOf(/*"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7",*/ "1.8")
382396
val latestVersion = versions.last()
383397

libraries/tools/kotlin-stdlib-docs/kotlin_big/build.gradle.kts

+6-26
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,12 @@ plugins {
22
base
33
}
44

5-
val isTeamcityBuild = project.hasProperty("teamcity.version")
6-
7-
// kotlin/libraries/tools/kotlin-stdlib-docs -> kotlin
8-
val kotlinRootDir = rootProject.file("../../../").absoluteFile.invariantSeparatorsPath
9-
val kotlinLibsDir = "$buildDir/libs"
10-
11-
val githubRevision = if (isTeamcityBuild) project.property("githubRevision") else "master"
12-
val kotlinVersion = if (isTeamcityBuild) project.property("deployVersion") as String else defaultSnapshotVersion()
13-
val repo = if (isTeamcityBuild) project.property("kotlinLibsRepo") as String else "$kotlinRootDir/build/repo"
14-
15-
fun defaultSnapshotVersion(): String = file(kotlinRootDir).resolve("gradle.properties").inputStream().use { stream ->
16-
java.util.Properties().apply { load(stream) }["defaultSnapshotVersion"] as String
17-
}
18-
19-
println("# Parameters summary:")
20-
println(" isTeamcityBuild: $isTeamcityBuild")
21-
println(" githubRevision: $githubRevision")
22-
println(" kotlinVersion: $kotlinVersion")
23-
println(" dokkaVersion: ${property("dokka_version")}")
24-
println(" repo: $repo")
5+
val artifactsVersion: String by project
6+
val artifactsRepo: String by project
7+
val kotlin_libs: String by project
258

269
repositories {
27-
maven(url = repo)
10+
maven(url = artifactsRepo)
2811
mavenCentral()
2912
}
3013

@@ -56,19 +39,16 @@ modules.forEach { module ->
5639
}
5740

5841
dependencies {
59-
library(group = "org.jetbrains.kotlin", name = module, version = kotlinVersion)
42+
library(group = "org.jetbrains.kotlin", name = module, version = artifactsVersion)
6043
}
6144

6245
val libsTask = tasks.register<Sync>("extract_lib_$module") {
6346
dependsOn(library)
6447

6548
from({ library })
66-
into("$kotlinLibsDir/$module")
49+
into("$kotlin_libs/$module")
6750
}
6851

6952
extractLibs.configure { dependsOn(libsTask) }
7053
}
7154

72-
project.ext["github_revision"] = githubRevision
73-
project.ext["kotlin_root"] = kotlinRootDir
74-
project.ext["kotlin_libs"] = kotlinLibsDir

0 commit comments

Comments
 (0)