Added option to specify the Kotlin compiler (kotlinc) path directly

This commit is contained in:
Erik C. Thauvin 2024-07-12 04:18:17 -07:00
parent 53681aa2ba
commit 7f3fc6ff95
Signed by: erik
GPG key ID: 776702A6A2DA330E
5 changed files with 118 additions and 64 deletions

View file

@ -1,4 +1,4 @@
# [Kotlin](https://kotlinlang.org/) Extension for [b<span style="color:orange">l</span>d](https://rife2.com/bld)
# [Kotlin](https://kotlinlang.org/) Extension for [b<span style="color:orange">l</span>d](https://rife2.com/bld)
[![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)
@ -8,7 +8,8 @@
[![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)
[![GitHub CI](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml)
To install, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) and [support](https://github.com/rife2/bld/wiki/Kotlin-Support)
To install, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions)
and [support](https://github.com/rife2/bld/wiki/Kotlin-Support)
documentation.
## Compile Kotlin Source Code
@ -16,6 +17,7 @@ documentation.
To compile the source code located in `src/main/kotlin` and `src/test/kotlin` from the current project:
```java
@BuildCommand(summary = "Compiles the Kotlin project")
public void compile() throws Exception {
new CompileKotlinOperation()
@ -30,16 +32,18 @@ public void compile() throws Exception {
- [View Examples Project](https://github.com/rife2/bld-kotlin/tree/main/examples/)
Please check the [Compile Operation documentation](https://rife2.github.io/bld-kotlin/rife/bld/extension/CompileKotlinOperation.html#method-summary)
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.
Please make sure the Kotlin compiler is [installed](https://kotlinlang.org/docs/command-line.html#install-the-compiler).
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()
@ -49,8 +53,23 @@ public void compile() throws Exception {
}
```
While older version of Kotlin are likely working with the extension, only version 1.9.24 or higher are officially supported.
The Kotlin compiler executable can also be specified directly:
```java
@BuildCommand(summary = "Compiles the Kotlin project")
public void compile() throws Exception {
new CompileKotlinOperation()
.fromProject(this)
.kotlinc("/usr/bin/kotlinc")
.execute();
}
```
While older version of Kotlin are likely working with the extension, only version 1.9.24 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.
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.