feat(hytale): add pinned adapter and reproducible build
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package dev.projectcapture.buildlogic;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.DirectoryProperty;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class VerifyFanProjectPolicy extends DefaultTask {
|
||||
@Internal
|
||||
public abstract DirectoryProperty getProjectRoot();
|
||||
|
||||
@TaskAction
|
||||
public void verify() throws IOException {
|
||||
File root = getProjectRoot().get().getAsFile();
|
||||
List<String> requiredFiles = List.of(
|
||||
"LICENSE",
|
||||
"THIRD_PARTY_NOTICE.md",
|
||||
"fan-project-metadata.json",
|
||||
"docs/UNOFFICIAL_FAN_PROJECT_POLICY.md"
|
||||
);
|
||||
List<String> missing = requiredFiles.stream()
|
||||
.filter(path -> !root.toPath().resolve(path).toFile().isFile())
|
||||
.toList();
|
||||
if (!missing.isEmpty()) {
|
||||
throw new GradleException("Missing fan-project safeguards: " + String.join(", ", missing));
|
||||
}
|
||||
|
||||
String metadata = Files.readString(root.toPath().resolve("fan-project-metadata.json"));
|
||||
List<String> requiredFlags = List.of(
|
||||
"\"unofficial\": true",
|
||||
"\"nonCommercial\": true",
|
||||
"\"containsPokemonFanContent\": true",
|
||||
"\"bundlesHytaleGameFiles\": false"
|
||||
);
|
||||
List<String> absentFlags = requiredFlags.stream()
|
||||
.filter(flag -> !metadata.contains(flag))
|
||||
.toList();
|
||||
if (!absentFlags.isEmpty()) {
|
||||
throw new GradleException("Invalid fan-project metadata; missing: " + String.join(", ", absentFlags));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user