8000 adding Kotlin DSL by DerEchtePilz · Pull Request #357 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

adding Kotlin DSL #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixing dependency leaks, adding Kotlin setup instructions to the docu…
…mentation
  • Loading branch information
DerEchtePilz committed Nov 3, 2022
commit 0215084e11d88d85a10bdb360ddd80ddd7407868
4 changes: 3 additions & 1 deletion commandapi-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
<jvmTarget>16</jvmTarget>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -114,6 +114,7 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand All @@ -125,6 +126,7 @@
<groupId>dev.jorel</groupId>
<artifactId>commandapi-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
121 changes: 121 additions & 0 deletions docssrc/src/kotlinintro.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,49 @@ Next, to shade it into your project easily, you need to add the `maven-shade-plu
</build>
```

Next, you need to add Kotlin to your project. For this, you first need to add the dependency:
```xml
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.7.20</version>
</dependency>
</dependencies>
```

Finally, you need to add the `kotlin-maven-plugin`:
```xml
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>1.7.20</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>16</jvmTarget>
</configuration>
</plugin>
</plugins>
</build>
```

### Adding the dependency with Gradle

First, you need to add the repository:
Expand Down Expand Up @@ -116,4 +159,82 @@ shadowJar {
}
```

</div>

You also need to add Kotlin to your project. For this, you first need to add the Kotlin plugin:

<div class="multi-pre">

```groovy,build.gradle
plugins {
id "org.jetbrains.kotlin.jvm" version "1.7.20"
}
```

```kotlin,build.gradle.kts
plugins {
kotlin("jvm") version "1.7.20"
}
```

</div>

Next, you need to add the dependency (you should already have added the `mavenCentral()` repository to your project):

<div class="multi-pre">

```groovy,build.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
```

```kotlin,build.gradle.kts
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
```

</div>

Then, you need to add the `compileKotlin` task:

<div class="multi-pre">

```groovy,build.gradle
compileKotlin {
kotlinOptions {
jvmTarget = "16"
}
}
```

```kotlin,build.gradle.kts
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "16"
}
```

</div>

Finally, you need to add it to the `shadowJar` configuration task and relocate it to your desired location:

<div class="multi-pre">

```groovy,build.gradle
shadowJar {
dependencies {
include dependency("org.jetbrains.kotlin:kotlin-stdlib")
}
}
```

```kotlin,build.gradle.kts
shadowJar {
dependencies {
include dependency("org.jetbrains.kotlin:kotlin-stdlib")
}
}
```

</div>
0