Skip to content

Commit 2cbde3b

Browse files
committed
Switch to Kotlin again, plus many changes:
+ API refactorings, for consistency and type-safety + Adds initial integration with Kotlin's Coroutines + Configures multi-modules build with common buildSrc definition
1 parent 2e44db1 commit 2cbde3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2850
-2243
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ktlint_ignore_back_ticked_identifier = true
99
indent_size = 4
1010
indent_style = space
1111

12-
max_line_length = 120
12+
max_line_length = 80
1313

1414
[Makefile]
1515
indent_style = tab

.sdkmanrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Enable auto-env through the sdkman_auto_env config
22
# Add key=value pairs of SDKs to use below
3-
# java=11.0.23-tem
4-
java=21-tem
3+
java=11.0.23-tem
4+
#java=21-tem

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```xml
66
<dependency>
77
<groupId>org.funfix</groupId>
8-
<artifactId>tasks-core</artifactId>
8+
<artifactId>tasks-core-jvm</artifactId>
99
<version>0.0.1</version>
1010
</dependency>
1111
```

build.gradle.kts

+4-46
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,16 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
33
val projectVersion = property("project.version").toString()
44

55
plugins {
6-
alias(libs.plugins.versions)
6+
id("org.jetbrains.dokka")
7+
id("com.github.ben-manes.versions")
78
}
89

910
repositories {
1011
mavenCentral()
1112
}
1213

13-
subprojects {
14-
group = "org.funfix"
15-
version = projectVersion.let { version ->
16-
if (!project.hasProperty("buildRelease"))
17-
"$version-SNAPSHOT"
18-
else
19-
version
20-
}
21-
22-
apply(plugin = "maven-publish")
23-
24-
configure<PublishingExtension> {
25-
repositories {
26-
mavenLocal()
27-
28-
maven {
29-
name = "GitHubPackages"
30-
url = uri("https://maven.pkg.github.com/funfix/tasks")
31-
credentials {
32-
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
33-
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
34-
}
35-
}
36-
37-
maven {
38-
name = "OSSRH"
39-
url = uri(
40-
if (project.hasProperty("buildRelease"))
41-
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
42-
else
43-
"https://oss.sonatype.org/content/repositories/snapshots/"
44-
)
45-
credentials {
46-
username = System.getenv("MAVEN_USERNAME")
47-
password = System.getenv("MAVEN_PASSWORD")
48-
}
49-
}
50-
}
51-
}
52-
53-
tasks.register("printVersion") {
54-
doLast {
55-
println("Project version: $version")
56-
}
57-
}
14+
tasks.dokkaHtmlMultiModule {
15+
outputDirectory.set(file("build/dokka"))
5816
}
5917

6018
tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {

buildSrc/build.gradle.kts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.io.FileInputStream
2+
import java.util.*
3+
4+
plugins {
5+
`kotlin-dsl`
6+
}
7+
8+
repositories {
9+
mavenCentral()
10+
gradlePluginPortal()
11+
}
12+
13+
val props = run {
14+
val projectProperties = Properties()
15+
val fis = FileInputStream("$rootDir/../gradle.properties")
16+
projectProperties.load(fis)
17+
projectProperties
18+
}
19+
20+
fun version(k: String) =
21+
props.getProperty("versions.$k")?.toString()
22+
23+
dependencies {
24+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${version("kotlin")}")
25+
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:${version("kotlinx.kover")}")
26+
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${version("dokka")}")
27+
implementation("com.github.ben-manes:gradle-versions-plugin:${version("gradle.versions")}")
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
plugins {
5+
id("org.jetbrains.kotlin.multiplatform")
6+
id("org.jetbrains.kotlinx.kover")
7+
id("org.jetbrains.dokka")
8+
id("maven-publish")
9+
id("signing")
10+
}
11+
12+
repositories {
13+
mavenCentral()
14+
}
15+
16+
group = "org.funfix"
17+
18+
val projectVersion = property("project.version").toString()
19+
version = projectVersion.let { version ->
20+
if (!project.hasProperty("buildRelease"))
21+
"$version-SNAPSHOT"
22+
else
23+
version
24+
}
25+
26+
publishing {
27+
repositories {
28+
mavenLocal()
29+
30+
maven {
31+
name = "GitHubPackages"
32+
url = uri("https://maven.pkg.github.com/funfix/tasks")
33+
credentials {
34+
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
35+
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
36+
}
37+
}
38+
}
39+
40+
publications {
41+
named<MavenPublication>("kotlinMultiplatform") {
42+
pom {
43+
url = "https://github.com/funfix/tasks"
44+
licenses {
45+
license {
46+
name = "The Apache License, Version 2.0"
47+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
48+
}
49+
}
50+
51+
developers {
52+
developer {
53+
id = "alexandru"
54+
name = "Alexandru Nedelcu"
55+
56+
}
57+
}
58+
59+
scm {
60+
connection = "scm:git:git://github.com/funfix/tasks.git"
61+
developerConnection = "scm:git:ssh://github.com/funfix/tasks.git"
62+
url = "https://github.com/funfix/tasks"
63+
}
64+
65+
issueManagement {
66+
system = "GitHub"
67+
url = "https://github.com/funfix/tasks/issues"
68+
}
69+
}
70+
}
71+
}
72+
}
73+
74+
val dokkaOutputDir = layout.buildDirectory.dir("dokka").get().asFile
75+
76+
tasks.dokkaHtml {
77+
outputDirectory.set(dokkaOutputDir)
78+
}
79+
80+
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
81+
delete(dokkaOutputDir)
82+
}
83+
84+
val javadocJar = tasks.create<Jar>("javadocJar") {
85+
archiveClassifier.set("javadoc")
86+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
87+
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
88+
from(dokkaOutputDir)
89+
}
90+
91+
java {
92+
sourceCompatibility = JavaVersion.VERSION_11
93+
targetCompatibility = JavaVersion.VERSION_11
94+
}
95+
96+
kotlin {
97+
jvm {
98+
withJava()
99+
}
100+
101+
js(IR) {
102+
browser {
103+
testTask {
104+
useKarma {
105+
useChromeHeadless()
106+
}
107+
}
108+
}
109+
}
110+
111+
tasks.withType<JavaCompile> {
112+
sourceCompatibility = "11"
113+
targetCompatibility = "11"
114+
}
115+
116+
tasks.withType<KotlinCompile> {
117+
compilerOptions {
118+
jvmTarget.set(JvmTarget.JVM_11)
119+
freeCompilerArgs.add("-Xjvm-default=all")
120+
}
121+
}
122+
123+
tasks.register<Test>("testsOn21") {
124+
javaLauncher =
125+
javaToolchains.launcherFor {
126+
languageVersion = JavaLanguageVersion.of(21)
127+
}
128+
}
129+
130+
tasks.register<Test>("testsOn11") {
131+
javaLauncher =
132+
javaToolchains.launcherFor {
133+
languageVersion = JavaLanguageVersion.of(11)
134+
}
135+
}
136+
}
137+
138+
tasks.withType<Test> {
139+
useJUnitPlatform()
140+
}
141+
142+
tasks.register("printInfo") {
143+
doLast {
144+
println("Group: $group")
145+
println("Project version: $version")
146+
}
147+
}

docs/vocabulary.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Vocabulary
2+
3+
* `execute` is used for executing a function or a task that may suspend side effects. The project uses `execute` instead of `run` or other synonyms. This is similar to Java's `Executor#execute`.
4+
* `join` is used for waiting for the completion of an already started fiber / thread, but without awaiting a final result.

gradle.properties

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ kotlin.code.style=official
22

33
# TO BE modified whenever a new version is released
44
project.version=0.0.1
5+
6+
versions.kotlin=2.0.0
7+
versions.kotlinx.kover=0.8.2
8+
versions.dokka=1.9.20
9+
versions.gradle.versions=0.51.0
10+
versions.kotlinx.coroutines.core=1.9.0-RC

settings.gradle.kts

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
rootProject.name = "tasks"
22

3-
include("tasks-core")
3+
include("tasks-core", "tasks-kotlin")
44

55
pluginManagement {
66
repositories {
@@ -17,13 +17,40 @@ plugins {
1717
dependencyResolutionManagement {
1818
versionCatalogs {
1919
create("libs") {
20-
// https://github.com/ben-manes/gradle-versions-plugin
21-
plugin("versions", "com.github.ben-manes.versions").version("0.51.0")
20+
version("kotlin", "2.0.0")
21+
//
22+
// // https://plugins.gradle.org/plugin/org.jetbrains.kotlin.jvm
23+
// plugin("kotlin-jvm", "org.jetbrains.kotlin.jvm")
24+
// .versionRef("kotlin")
25+
// plugin("kotlin-multiplatform", "org.jetbrains.kotlin.multiplatform")
26+
// .versionRef("kotlin")
27+
// // https://github.com/Kotlin/kotlinx-kover
28+
// plugin("kotlinx-kover", "org.jetbrains.kotlinx.kover")
29+
// .version("0.8.2")
30+
// // https://github.com/ben-manes/gradle-versions-plugin
31+
// plugin("versions", "com.github.ben-manes.versions")
32+
// .version("0.51.0")
33+
// // https://github.com/Kotlin/dokka
34+
// plugin("dokka", "org.jetbrains.dokka")
35+
// .version("1.9.20")
36+
37+
// https://github.com/Kotlin/kotlinx.coroutines
38+
library("kotlinx-coroutines-core", "org.jetbrains.kotlinx", "kotlinx-coroutines-core")
39+
.version("1.9.0-RC")
2240

2341
// https://jspecify.dev/docs/start-here
2442
library("jspecify", "org.jspecify", "jspecify")
2543
.version("0.3.0")
44+
library("jetbrains-annotations", "org.jetbrains", "annotations")
45+
.version("24.1.0")
2646

47+
// https://kotlinlang.org/api/latest/kotlin.test/
48+
library("kotlin-test", "org.jetbrains.kotlin", "kotlin-test")
49+
.versionRef("kotlin")
50+
library("kotlin-test-common", "org.jetbrains.kotlin", "kotlin-test-common")
51+
.versionRef("kotlin")
52+
library("kotlin-test-annotations-common", "org.jetbrains.kotlin", "kotlin-test-annotations-common")
53+
.versionRef("kotlin")
2754
library("junit-jupiter-api", "org.junit.jupiter", "junit-jupiter-api")
2855
.version("5.10.2")
2956
}

0 commit comments

Comments
 (0)