Add simple utility method for defining an entrypoint with a language adapter (#1451)

This commit is contained in:
Ellie McQuinn
2025-11-17 19:19:55 +00:00
committed by GitHub
parent 10802d5424
commit 408ff16767
2 changed files with 18 additions and 0 deletions

View File

@@ -122,6 +122,19 @@ public abstract class FabricModJsonV1Spec {
entrypoint(entrypoint, value, metadata -> { });
}
/**
* Add a new entrypoint with the given name, value, and language adapter.
*
* @param entrypoint The name of the entrypoint, such as "main" or "client"
* @param value The value of the entrypoint, typically a fully qualified class name
* @param adapter The language adapter of the entrypoint, such as "kotlin" or "scala"
*/
public void entrypoint(String entrypoint, String value, String adapter) {
entrypoint(entrypoint, value, metadata -> {
metadata.getAdapter().set(adapter);
});
}
/**
* Add a new entrypoint with the given name and value, and configure it with the given action.
*

View File

@@ -303,6 +303,7 @@ class FabricModJsonV1GeneratorTest extends Specification {
spec.entrypoint("client", "com.example.KotlinClient::init") {
it.adapter.set("kotlin")
}
spec.entrypoint("client", "com.example.KotlinClient", "kotlin")
spec.entrypoint("client") {
it.value.set("com.example.Client")
}
@@ -322,6 +323,10 @@ class FabricModJsonV1GeneratorTest extends Specification {
"value": "com.example.KotlinClient::init",
"adapter": "kotlin"
},
{
"value": "com.example.KotlinClient",
"adapter": "kotlin"
},
"com.example.Client"
],
"main": [