Skip to content

Commit

Permalink
Let the plugin handle Kotlin stdlib and compile avoidance
Browse files Browse the repository at this point in the history
  • Loading branch information
GlennFolker committed Dec 19, 2023
1 parent 8b25336 commit 8e23374
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ This project is licensed under [GNU GPL v3](/LICENSE).
## Version Compatibility
| `Mindustry`/`Arc` | `EntityAnno` |
|-------------------|----------------------|
| `v146` | `v146.0.0`, `v1.2.0` |
| `v146` | `v146.0.1`, `v1.2.0` |
| `v145` | `1.1.2` |
| `v144.3` | `1.0.0` |
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ configure(allprojects){

sourceSets.main.java.srcDirs = [layout.projectDirectory.dir('src')]

version = 'v146.0.0'
version = 'v146.0.1'
ext{
compilerVersion = JavaVersion.current().ordinal() - JavaVersion.VERSION_17.ordinal() + 17

Expand Down
14 changes: 11 additions & 3 deletions src/ent/EntityAnnoPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import org.jetbrains.kotlin.gradle.internal.*;
import org.jetbrains.kotlin.gradle.plugin.*;
import org.jetbrains.kotlin.gradle.plugin.diagnostics.*;
import org.jetbrains.kotlin.gradle.tasks.*;
import org.jetbrains.kotlin.gradle.tasks.Kapt;
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;

import java.io.*;
import java.util.concurrent.*;
Expand All @@ -30,6 +31,10 @@ public void apply(Project project){
var exts = project.getExtensions();
var tasks = project.getTasks();

var props = exts.getByType(ExtraPropertiesExtension.class);
// Don't include Kotlin standard libraries, we absolutely do not need those bloats.
props.set("kotlin.stdlib.default.dependency", "false");

// Apply 'java', 'kotlin-jvm', and 'kotlin-kapt' plugins.
plugins.apply("java");
plugins.apply(KotlinPluginWrapper.class);
Expand Down Expand Up @@ -128,8 +133,11 @@ public void apply(Project project){
return null;
});

// Add fetched sources as KAPT input.
tasks.withType(Kapt.class, task -> task.getInputs().files(fetchComps));
// Add fetched sources as KAPT input, and enable compile avoidance.
tasks.withType(Kapt.class, task -> {
task.getInputs().files(fetchComps);
task.getIncludeCompileClasspath().set(false);
});

// Add `fetchDir` and KAPT output as Java source sets.
exts.getByType(JavaPluginExtension.class)
Expand Down

0 comments on commit 8e23374

Please sign in to comment.