Skip to content

Commit 8040af8

Browse files
authored
Update the project structure to work with kotlin-master (#234)
1 parent e5cd71b commit 8040af8

30 files changed

+97
-59
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
enum class ActionApplied {
13+
Applied, NotApplied;
14+
}
15+
16+
@Suppress("unused")
17+
inline fun ExtensionAware.whenKotlinIsAtLeast(
18+
major: Int,
19+
minor: Int,
20+
patch: Int = 0,
21+
action: () -> Unit = {},
22+
): ActionApplied {
23+
val kotlinVersion: KotlinVersion by extra
24+
25+
if (kotlinVersion.isAtLeast(major, minor, patch)) {
26+
action()
27+
28+
return ActionApplied.Applied
29+
}
30+
31+
return ActionApplied.NotApplied
32+
}
33+
34+
inline fun ExtensionAware.whenKotlinLatest(action: () -> Unit): ActionApplied {
35+
val isLatestKotlinVersion: Boolean by extra
36+
37+
if (isLatestKotlinVersion) {
38+
action()
39+
return ActionApplied.Applied
40+
}
41+
42+
return ActionApplied.NotApplied
43+
}
44+
45+
infix fun ActionApplied.otherwise(body: () -> Unit) {
46+
if (this == ActionApplied.NotApplied) {
47+
body()
48+
}
49+
}

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
File renamed without changes.
File renamed without changes.
File renamed without changes.

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)