Remove usage of internal kotlin class, should fix crash with kotlin 1.4. Closes #324

dev/0.11
modmuss50 2021-01-07 20:35:09 +00:00
parent e61f3fb362
commit 9de836b2c4
1 changed files with 11 additions and 2 deletions

View File

@ -35,9 +35,9 @@ import java.util.stream.Collectors;
import kotlin.Unit; import kotlin.Unit;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.compile.JavaCompile;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin;
import org.jetbrains.kotlin.gradle.plugin.KaptExtension; import org.jetbrains.kotlin.gradle.plugin.KaptExtension;
import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradleExtension;
@ -92,10 +92,19 @@ public class KaptApInvoker extends AnnotationProcessorInvoker<JavaCompile> {
// Kapt generates an AP configuration for every source set based off of the getKaptConfigurationName method. // Kapt generates an AP configuration for every source set based off of the getKaptConfigurationName method.
return AnnotationProcessorInvoker.getNonTestSourceSets(project) return AnnotationProcessorInvoker.getNonTestSourceSets(project)
.map(sourceSet -> project.getConfigurations() .map(sourceSet -> project.getConfigurations()
.getByName(Kapt3KotlinGradleSubplugin.Companion.getKaptConfigurationName(sourceSet.getName())) .getByName(getKaptConfigurationName(sourceSet.getName()))
).collect(Collectors.toList()); ).collect(Collectors.toList());
} }
// Pulled out from the internal class: https://github.com/JetBrains/kotlin/blob/33a0ec9b4f40f3d6f1f96b2db504ade4c2fafe03/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/Kapt3KotlinGradleSubplugin.kt#L92
private static String getKaptConfigurationName(String sourceSetName) {
if (!sourceSetName.equals(SourceSet.MAIN_SOURCE_SET_NAME)) {
return "kapt" + (sourceSetName.substring(0, 1).toUpperCase() + sourceSetName.substring(1));
}
return "kapt";
}
@Override @Override
protected void passArgument(JavaCompile compileTask, String key, String value) { protected void passArgument(JavaCompile compileTask, String key, String value) {
// Note: this MUST be run early on, before kapt uses this data, and there is only a point to setting the value once since // Note: this MUST be run early on, before kapt uses this data, and there is only a point to setting the value once since