Improve kotlin plugin version retrieval.

Update FLK in test.
This commit is contained in:
modmuss50
2022-04-17 20:20:50 +01:00
parent ba2c98f7fd
commit 0fda2a07bd
3 changed files with 4 additions and 16 deletions

View File

@@ -25,28 +25,16 @@
package net.fabricmc.loom.util.kotlin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.DependencySet;
public class KotlinPluginUtils {
private static final String KOTLIN_PLUGIN_ID = "org.jetbrains.kotlin.jvm";
private static final String KOTLIN_PLUGIN_GROUP = "org.jetbrains.kotlin.jvm";
private static final String KOTLIN_PLUGIN_NAME = "org.jetbrains.kotlin.jvm.gradle.plugin";
public static boolean hasKotlinPlugin(Project project) {
return project.getPluginManager().hasPlugin(KOTLIN_PLUGIN_ID);
}
public static String getKotlinPluginVersion(Project project) {
DependencySet buildDependencies = project.getBuildscript().getConfigurations()
.getByName("classpath").getDependencies();
for (Dependency dependency : buildDependencies) {
if (KOTLIN_PLUGIN_GROUP.equals(dependency.getGroup()) && KOTLIN_PLUGIN_NAME.equals(dependency.getName())) {
return dependency.getVersion();
}
}
throw new IllegalStateException("Unable to get the kotlin plugin version");
Class<?> koltinPluginClass = project.getPlugins().getPlugin(KOTLIN_PLUGIN_ID).getClass();
return koltinPluginClass.getPackage().getImplementationVersion().split("-")[0];
}
}

View File

@@ -39,7 +39,7 @@ class KotlinTest extends Specification implements GradleProjectTestTrait {
def gradle = gradleProject(project: "kotlin", version: version)
def server = ServerRunner.create(gradle.projectDir, "1.16.5")
.withMod(gradle.getOutputFile("fabric-example-mod-0.0.1.jar"))
.downloadMod(ServerRunner.FABRIC_LANG_KOTLIN, "fabric-language-kotlin-1.7.1+kotlin.1.6.10.jar")
.downloadMod(ServerRunner.FABRIC_LANG_KOTLIN, "fabric-language-kotlin-1.7.3+kotlin.1.6.20.jar")
when:
def result = gradle.run(task: "build")

View File

@@ -34,7 +34,7 @@ class ServerRunner {
"1.16.5": "https://github.com/FabricMC/fabric/releases/download/0.37.1%2B1.16/fabric-api-0.37.1+1.16.jar",
"1.17.1": "https://github.com/FabricMC/fabric/releases/download/0.37.1%2B1.17/fabric-api-0.37.1+1.17.jar"
]
static final String FABRIC_LANG_KOTLIN = "https://maven.fabricmc.net/net/fabricmc/fabric-language-kotlin/1.7.1%2Bkotlin.1.6.10/fabric-language-kotlin-1.7.1%2Bkotlin.1.6.10.jar"
static final String FABRIC_LANG_KOTLIN = "https://maven.fabricmc.net/net/fabricmc/fabric-language-kotlin/1.7.3%2Bkotlin.1.6.20/fabric-language-kotlin-1.7.3%2Bkotlin.1.6.20.jar"
final File serverDir
final String minecraftVersion