48 lines
1.8 KiB
Groovy
48 lines
1.8 KiB
Groovy
import java.util.stream.Collectors
|
|
import java.nio.file.Files
|
|
import java.nio.file.Path
|
|
|
|
apply from: "https://jfmods.gitlab.io/scripts/gradle/v2.gradle"
|
|
|
|
ext.flavor = project.hasProperty('flavor') ? project.getProperty('flavor') : 'modrinth'
|
|
|
|
dependencies {
|
|
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:$project.libjf_version")
|
|
|
|
// Dev env
|
|
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:$project.libjf_version")
|
|
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:$project.libjf_version")
|
|
modLocalRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
|
|
modLocalRuntime("com.terraformersmc:modmenu:4.0.6")
|
|
}
|
|
|
|
def list(String dir) {
|
|
return Files.list(Path.of("$projectDir/$dir"))
|
|
.map(p -> p.fileName.toString())
|
|
.map(p -> p.substring(0, p.lastIndexOf('.')))
|
|
.filter(p -> p.endsWith("Provider"))
|
|
.toArray(String[]::new)
|
|
}
|
|
|
|
String[] paths = list("src/main/java/io/gitlab/jfronny/breakme/crash/safe")
|
|
|
|
if (flavor == "curseforge") {
|
|
sourceSets.main.java.filter.exclude("**/unsafe/*")
|
|
sourceSets.main.resources.exclude("**/native/*")
|
|
} else {
|
|
paths += list("src/main/java/io/gitlab/jfronny/breakme/crash/unsafe")
|
|
}
|
|
|
|
Files.writeString(Path.of("$projectDir/src/main/java/io/gitlab/jfronny/breakme/crash/KnownProviders.java"), """
|
|
package io.gitlab.jfronny.breakme.crash;
|
|
|
|
import io.gitlab.jfronny.breakme.crash.safe.*;
|
|
${if (flavor == "curseforge") "" else "import io.gitlab.jfronny.breakme.crash.unsafe.*;"}
|
|
import java.util.Map;
|
|
|
|
public class KnownProviders {
|
|
public static final Map<String, CrashProvider> PROVIDERS = Map.of(
|
|
${Arrays.stream(paths).map(path -> "\"${path.substring(0, path.length() - "Provider".length())}\", new $path()").collect(Collectors.joining(",\n "))}
|
|
);
|
|
}
|
|
""") |