Skip to content

Commit

Permalink
BREAKING CHANGE: Kotlin must be installed. Location is deducted from …
Browse files Browse the repository at this point in the history
…KOTLIN_HOME, if set.
  • Loading branch information
ethauvin committed Jul 12, 2024
1 parent c84019d commit 6fa3bde
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 96 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bld.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
strategy:
matrix:
java-version: [17, 21, 22]
kotlin-version: [1.9.24, 2.0.0]

steps:
- name: Checkout source repository
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
[![Kotlin](https://img.shields.io/badge/kotlin-2.0.0-7f52ff.svg)](https://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9%2B-7f52ff.svg)](https://kotlinlang.org)
[![bld](https://img.shields.io/badge/1.9.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
[![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-kotlin)
[![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-kotlin)
Expand Down Expand Up @@ -33,6 +33,24 @@ public void compile() throws Exception {
Please check the [Compile Operation documentation](https://rife2.github.io/bld-kotlin/rife/bld/extension/CompileKotlinOperation.html#method-summary)
for all available configuration options.

## Kotlin Compiler Requirement

Please make sure Kotlin is installed and that the `KOTLIN_HOME` environment variable is set.

You can also manually configure the Kotlin home location as follows:

```java
@BuildCommand(summary = "Compiles the Kotlin project")
public void compile() throws Exception {
new CompileKotlinOperation()
.fromProject(this)
.kotlinHome("path/to/kotlin")
.execute();
}
```

While older version of Kotlin are likely working with the extension, only version 1.9 or higher are officially supported.

## Template Project

There is also a [Template Project](https://github.com/rife2/kotlin-bld-example) with support for the [Dokka](https://github.com/rife2/bld-dokka) and [Detekt](https://github.com/rife2/bld-detekt) extensions.
9 changes: 5 additions & 4 deletions scripts/checkcliargs.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

main=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
new=/tmp/checkcliargs-new
old=/tmp/checkcliargs-old

java -cp "lib/compile/*" $main -h 2>$new
java -cp "examples/lib/bld/*" $main -h 2>$old
kotlinc -h 2>$new
~/.sdkman/candidates/kotlin/2.0.0/bin/kotlinc -h 2>$old

diff $old $new
code --diff --wait $old $new

rm -rf $new $old
2 changes: 1 addition & 1 deletion scripts/cliargs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

java -cp "lib/compile/*" org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -h 2> >(grep "^ ") |\
kotlinc -h 2> >(grep "^ ") |\
sed -e "s/^ //" -e "s/ .*//" -e "s/<.*//" -e '/-help/d' -e '/-version/d' -e '/^$/d'|\
sort > "src/test/resources/kotlinc-args.txt"
16 changes: 0 additions & 16 deletions src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,7 @@ public CompileKotlinOperationBuild() {

repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);

var kotlin = version(2, 0, 0);
scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-compiler", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-annotation-processing", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-scripting-compiler", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-reflect", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-common", kotlin))
.include(dependency("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm", version(1, 9, 0, "RC")))
// Compiler Plugins
.include(dependency("org.jetbrains.kotlin", "kotlin-allopen-compiler-plugin", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-assignment-compiler-plugin", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-serialization-compiler-plugin", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-lombok-compiler-plugin", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-allopen-compiler-plugin", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-noarg-compiler-plugin", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-power-assert-compiler-plugin", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-sam-with-receiver-compiler-plugin", kotlin))
.include(dependency("com.uwyn.rife2", "bld", version(2, 0, 0, "SNAPSHOT")));
scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3)))
Expand Down
Loading

0 comments on commit 6fa3bde

Please sign in to comment.