Skip to content

Commit aa93f80

Browse files
committed
Update the project structure to work with kotlin-master
1 parent e5cd71b commit aa93f80

30 files changed

+92
-58
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Ignore Gradle build output directory
55
build
66
.kotlin
7-
7+
lib-kotlin
88
# idea files
99
.idea/*
1010
!.idea/runConfigurations

gradle-conventions-settings/build.gradle.kts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,7 @@ configurations.configureEach {
1515
}
1616
}
1717

18-
val isLatestKotlinVersion: Boolean by extra
19-
2018
dependencies {
21-
api(libs.kotlin.gradle.plugin)
22-
api(libs.detekt.gradle.plugin)
23-
api(libs.binary.compatibility.validator.gradle.plugin)
24-
25-
if (isLatestKotlinVersion) {
26-
api(libs.kover.gradle.plugin)
27-
}
28-
2919
// https://stackoverflow.com/questions/76713758/use-version-catalog-inside-precompiled-gradle-plugin
3020
api(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
3121
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package util
6+
7+
import org.gradle.api.plugins.ExtensionAware
8+
import org.gradle.kotlin.dsl.extra
9+
import org.gradle.kotlin.dsl.provideDelegate
10+
11+
12+
data class ActionApplied(val applied: Boolean)
13+
14+
@Suppress("unused")
15+
inline fun ExtensionAware.whenKotlinIsAtLeast(
16+
major: Int,
17+
minor: Int,
18+
patch: Int = 0,
19+
action: () -> Unit = {},
20+
): ActionApplied {
21+
val kotlinVersion: KotlinVersion by extra
22+
23+
if (kotlinVersion.isAtLeast(major, minor, patch)) {
24+
action()
25+
26+
return ActionApplied(true)
27+
}
28+
29+
return ActionApplied(false)
30+
}
31+
32+
inline fun ExtensionAware.whenKotlinLatest(action: () -> Unit): ActionApplied {
33+
val isLatestKotlinVersion: Boolean by extra
34+
35+
if (isLatestKotlinVersion) {
36+
action()
37+
}
38+
39+
return ActionApplied(isLatestKotlinVersion)
40+
}
41+
42+
infix fun ActionApplied.otherwise(body: () -> Unit) {
43+
if (!applied) {
44+
body()
45+
}
46+
}

gradle-conventions/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ plugins {
1010
alias(libs.plugins.gradle.kotlin.dsl)
1111
}
1212

13-
// chicken-egg
14-
apply(from = "src/main/kotlin/compiler-specific-module.gradle.kts")
15-
1613
defaultConventionConfiguration()
1714

1815
dependencies {
16+
implementation(project(":common"))
1917
implementation(":gradle-conventions-settings")
2018

2119
project.whenKotlinLatest {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import util.defaultConventionConfiguration
6+
7+
plugins {
8+
alias(libs.plugins.gradle.kotlin.dsl)
9+
}
10+
11+
defaultConventionConfiguration()
12+
13+
val isLatestKotlinVersion: Boolean by extra
14+
15+
dependencies {
16+
implementation(":gradle-conventions-settings")
17+
18+
api(libs.kotlin.gradle.plugin)
19+
api(libs.detekt.gradle.plugin)
20+
api(libs.binary.compatibility.validator.gradle.plugin)
21+
22+
if (isLatestKotlinVersion) {
23+
api(libs.kover.gradle.plugin)
24+
}
25+
26+
// https://stackoverflow.com/questions/76713758/use-version-catalog-inside-precompiled-gradle-plugin
27+
api(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
28+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
// empty

gradle-conventions-settings/src/main/kotlin/util/KotlinVersion.kt renamed to gradle-conventions/common/src/main/kotlin/util/KotlinVersion.kt

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
package util
66

7-
import org.gradle.api.plugins.ExtensionAware
8-
import org.gradle.kotlin.dsl.extra
97
import org.gradle.kotlin.dsl.provideDelegate
108
import java.io.File
119
import java.nio.file.Files
@@ -87,39 +85,3 @@ private fun Collection<File>.mostSpecificByVersionOrNull(kotlinVersion: KotlinVe
8785
// - pre_1_9_20
8886
// etc.
8987
private val directoryNameRegex = "^(latest|(v|pre)(_\\d){1,3}\\d?)$".toRegex()
90-
91-
data class ActionApplied(val applied: Boolean)
92-
93-
@Suppress("unused")
94-
inline fun ExtensionAware.whenKotlinIsAtLeast(
95-
major: Int,
96-
minor: Int,
97-
patch: Int = 0,
98-
action: () -> Unit = {},
99-
): ActionApplied {
100-
val kotlinVersion: KotlinVersion by extra
101-
102-
if (kotlinVersion.isAtLeast(major, minor, patch)) {
103-
action()
104-
105-
return ActionApplied(true)
106-
}
107-
108-
return ActionApplied(false)
109-
}
110-
111-
inline fun ExtensionAware.whenKotlinLatest(action: () -> Unit): ActionApplied {
112-
val isLatestKotlinVersion: Boolean by extra
113-
114-
if (isLatestKotlinVersion) {
115-
action()
116-
}
117-
118-
return ActionApplied(isLatestKotlinVersion)
119-
}
120-
121-
infix fun ActionApplied.otherwise(body: () -> Unit) {
122-
if (!applied) {
123-
body()
124-
}
125-
}

0 commit comments

Comments
 (0)