Add mod setup tools and project initialization support.
This commit is contained in:
1 parent
a5766f3a1b
commit
32fab0c1d4
9 files changed
+684
-55
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// Gradle plugin for mod authors (id dev.overlord.zomboidforge.mod): dependencies, mod.toml,
|
||||
// build-time checks, packaging, and a local test server. Runs inside the mod's Gradle JVM, so
|
||||
// it targets Java 17; the checks run in a separate Java 25 process (mod-tools).
|
||||
// Gradle plugins for mod authors (ids dev.overlord.zomboidforge for settings.gradle.kts and
|
||||
// dev.overlord.zomboidforge.mod): dependencies, mod.toml, build-time checks, packaging, and a
|
||||
// local test server. Runs inside the mod's Gradle JVM, so it targets Java 17; the checks run in
|
||||
// a separate Java 25 process (mod-tools).
|
||||
|
||||
plugins {
|
||||
id("zomboidforge.java-conventions")
|
||||
@@ -20,6 +21,13 @@ gradlePlugin {
|
||||
displayName = "ZomboidForge mod"
|
||||
description = "Builds, checks, and packages server-side Java mods for ZomboidForge."
|
||||
}
|
||||
|
||||
create("settings") {
|
||||
id = "dev.overlord.zomboidforge"
|
||||
implementationClass = "dev.overlord.zomboidforge.gradle.ZomboidForgeSettingsPlugin"
|
||||
displayName = "ZomboidForge mod project"
|
||||
description = "Makes a ZomboidForge mod project a single settings.gradle.kts."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +46,19 @@ dependencies {
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
// The functional tests resolve api and mod-tools from the repository in build/repo.
|
||||
dependsOn(":api:publishAllPublicationsToBuildRepository", ":mod-tools:publishAllPublicationsToBuildRepository")
|
||||
// The functional tests resolve api and mod-tools from the repository in build/repo, the
|
||||
// updater tests the plugin as well.
|
||||
dependsOn(
|
||||
":api:publishAllPublicationsToBuildRepository",
|
||||
":mod-tools:publishAllPublicationsToBuildRepository",
|
||||
"publishAllPublicationsToBuildRepository",
|
||||
)
|
||||
|
||||
val repository = layout.settingsDirectory.dir("build/repo").asFile.absolutePath
|
||||
systemProperty("zomboidforge.testRepository", repository)
|
||||
|
||||
// The updater tests run zomboidforge.jsh with the wrapper of the repository root.
|
||||
val root = layout.settingsDirectory.asFile.absolutePath
|
||||
inputs.file(layout.settingsDirectory.file("zomboidforge.jsh"))
|
||||
systemProperty("zomboidforge.root", root)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package dev.overlord.zomboidforge.gradle;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.file.DirectoryProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.tasks.UntrackedTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Creates the files a new mod project needs and does not have yet: {@code .gitignore} and the
|
||||
* entry point class with an empty {@code onLoad()}. Existing files stay as they are.
|
||||
*/
|
||||
@UntrackedTask(because = "Creates missing files once and never changes existing ones")
|
||||
public abstract class SetupMod extends DefaultTask
|
||||
{
|
||||
private static final String GITIGNORE = """
|
||||
.gradle/
|
||||
build/
|
||||
""";
|
||||
|
||||
private static final String ENTRY_POINT = """
|
||||
%simport dev.overlord.zomboidforge.api.Mod;
|
||||
|
||||
public final class %s extends Mod
|
||||
{
|
||||
@Override
|
||||
public void onLoad() {}
|
||||
}
|
||||
""";
|
||||
|
||||
@Internal
|
||||
public abstract DirectoryProperty getProjectDirectory();
|
||||
|
||||
@Input
|
||||
public abstract Property<String> getEntrypoint();
|
||||
|
||||
@TaskAction
|
||||
public void setup() throws IOException
|
||||
{
|
||||
Path directory = this.getProjectDirectory().get().getAsFile().toPath();
|
||||
String entrypoint = this.getEntrypoint().get();
|
||||
int dot = entrypoint.lastIndexOf('.');
|
||||
String packageLine = dot < 0 ? "" : "package " + entrypoint.substring(0, dot) + ";\n\n";
|
||||
String className = entrypoint.substring(dot + 1);
|
||||
|
||||
this.create(directory, ".gitignore", SetupMod.GITIGNORE);
|
||||
this.create(directory, "src/main/java/" + entrypoint.replace('.', '/') + ".java", SetupMod.ENTRY_POINT.formatted(packageLine, className));
|
||||
}
|
||||
|
||||
private void create(Path directory, String path, String content) throws IOException
|
||||
{
|
||||
Path file = directory.resolve(path);
|
||||
|
||||
if (Files.exists(file)) return;
|
||||
|
||||
Files.createDirectories(file.getParent());
|
||||
Files.writeString(file, content);
|
||||
this.getLogger().lifecycle("Created '{}'.", path);
|
||||
}
|
||||
}
|
||||
+28
-3
@@ -42,14 +42,20 @@ import java.util.Properties;
|
||||
* <li>{@code runServer}: a ZomboidForge server in a container with the mod;
|
||||
* {@code deployMod}: copies the mod into a server's mods directory;</li>
|
||||
* <li>{@code downloadGame}: installs the dedicated server with steamcmd when no game jar is
|
||||
* configured or installed.</li>
|
||||
* configured or installed;</li>
|
||||
* <li>{@code zomboidForgeSetup}: creates {@code .gitignore} and the entry point class when
|
||||
* they are missing.</li>
|
||||
* </ul>
|
||||
*
|
||||
* Uses the {@code zomboidForge { }} of {@code dev.overlord.zomboidforge} when the settings
|
||||
* apply it.
|
||||
*
|
||||
* Java compiles for Java 25 (the game's runtime) unless the build sets another toolchain.
|
||||
*/
|
||||
public final class ZomboidForgeModPlugin implements Plugin<Project>
|
||||
{
|
||||
public static final String GROUP = "zomboidforge";
|
||||
public static final String GROUP = "zomboidforge";
|
||||
public static final String EXTENSION = "zomboidForge";
|
||||
|
||||
private static final String API = "dev.overlord.zomboidforge:api:";
|
||||
private static final String TOOLS = "dev.overlord.zomboidforge:mod-tools:";
|
||||
@@ -66,7 +72,7 @@ public final class ZomboidForgeModPlugin implements Plugin<Project>
|
||||
String version = ZomboidForgeModPlugin.version();
|
||||
ProjectLayout layout = project.getLayout();
|
||||
DependencyHandler handler = project.getDependencies();
|
||||
ZomboidForgeExtension extension = project.getExtensions().create("zomboidForge", ZomboidForgeExtension.class);
|
||||
ZomboidForgeExtension extension = ZomboidForgeModPlugin.extension(project);
|
||||
|
||||
extension.getName().convention(extension.getId());
|
||||
extension.getVersion().convention(project.provider(() -> project.getVersion().toString()));
|
||||
@@ -247,6 +253,25 @@ public final class ZomboidForgeModPlugin implements Plugin<Project>
|
||||
task.into(extension.getDeployDirectory().dir(id).orElse(layout.getBuildDirectory().dir("deploy-not-configured")));
|
||||
task.onlyIf("zomboidForge.deployDirectory is set", element -> extension.getDeployDirectory().isPresent());
|
||||
});
|
||||
|
||||
// Project setup.
|
||||
TaskProvider<SetupMod> setup = project.getTasks().register("zomboidForgeSetup", SetupMod.class, task ->
|
||||
{
|
||||
task.setGroup(ZomboidForgeModPlugin.GROUP);
|
||||
task.setDescription("Creates .gitignore and the entry point class when they are missing.");
|
||||
task.getProjectDirectory().set(layout.getProjectDirectory());
|
||||
task.getEntrypoint().set(extension.getEntrypoint());
|
||||
});
|
||||
|
||||
project.getTasks().named(JavaPlugin.COMPILE_JAVA_TASK_NAME, task -> task.mustRunAfter(setup));
|
||||
}
|
||||
|
||||
/** The {@code zomboidForge { }} of the settings plugin, else a new one. */
|
||||
private static ZomboidForgeExtension extension(Project project)
|
||||
{
|
||||
ZomboidForgeExtension shared = project.getExtensions().findByType(ZomboidForgeExtension.class);
|
||||
|
||||
return shared != null ? shared : project.getExtensions().create(ZomboidForgeModPlugin.EXTENSION, ZomboidForgeExtension.class);
|
||||
}
|
||||
|
||||
/** The plugin's version, which is also the version of the API and mod tools it uses. */
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package dev.overlord.zomboidforge.gradle;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.initialization.Settings;
|
||||
import org.gradle.api.provider.Provider;
|
||||
|
||||
/**
|
||||
* The plugin {@code dev.overlord.zomboidforge} for {@code settings.gradle.kts}, which makes a
|
||||
* mod project a single file:
|
||||
*
|
||||
* <pre>{@code
|
||||
* plugins {
|
||||
* id("dev.overlord.zomboidforge") version "0.6.0"
|
||||
* }
|
||||
*
|
||||
* zomboidForge {
|
||||
* id = "shop"
|
||||
* entrypoint = "com.example.shop.ShopMod"
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* Adds {@code zomboidForge { }} to the settings and names the root project after the mod id.
|
||||
* The root project gets the ZomboidForge Maven registry and Maven Central as repositories, and
|
||||
* {@code dev.overlord.zomboidforge.mod} with the same {@code zomboidForge { }}. The Gradle
|
||||
* property {@code zomboidforge.repository} replaces the registry's URL.
|
||||
*/
|
||||
public final class ZomboidForgeSettingsPlugin implements Plugin<Settings>
|
||||
{
|
||||
static final String REPOSITORY = "https://git.security-command.org/api/packages/overlord/maven";
|
||||
|
||||
@Override
|
||||
public void apply(Settings settings)
|
||||
{
|
||||
ZomboidForgeExtension extension = settings.getExtensions().create(ZomboidForgeModPlugin.EXTENSION, ZomboidForgeExtension.class);
|
||||
Provider<String> repository = settings.getProviders().gradleProperty("zomboidforge.repository").orElse(ZomboidForgeSettingsPlugin.REPOSITORY);
|
||||
|
||||
settings.getGradle().settingsEvaluated(evaluated ->
|
||||
{
|
||||
if (extension.getId().isPresent()) evaluated.getRootProject().setName(extension.getId().get());
|
||||
});
|
||||
|
||||
settings.getGradle().rootProject(project ->
|
||||
{
|
||||
project.getRepositories().maven(maven -> maven.setUrl(repository.get()));
|
||||
project.getRepositories().mavenCentral();
|
||||
project.getExtensions().add(ZomboidForgeExtension.class, ZomboidForgeModPlugin.EXTENSION, extension);
|
||||
project.getPluginManager().apply(ZomboidForgeModPlugin.class);
|
||||
});
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package dev.overlord.zomboidforge.gradle;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.GradleRunner;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/** Builds mod projects that consist of a settings.gradle.kts with dev.overlord.zomboidforge. */
|
||||
class ZomboidForgeSettingsPluginTest
|
||||
{
|
||||
private static final String REPOSITORY = System.getProperty("zomboidforge.testRepository");
|
||||
|
||||
private static final String SETTINGS = """
|
||||
plugins {
|
||||
id("dev.overlord.zomboidforge")
|
||||
}
|
||||
|
||||
zomboidForge {
|
||||
id = "shop"
|
||||
version = "1.0.0"
|
||||
entrypoint = "com.example.shop.ShopMod"
|
||||
}
|
||||
""";
|
||||
|
||||
@TempDir
|
||||
Path project;
|
||||
|
||||
private void write(String path, String content) throws IOException
|
||||
{
|
||||
Path file = this.project.resolve(path);
|
||||
Files.createDirectories(file.getParent());
|
||||
Files.writeString(file, content);
|
||||
}
|
||||
|
||||
private GradleRunner runner(String... arguments)
|
||||
{
|
||||
List<String> all = new ArrayList<>(List.of(arguments));
|
||||
all.add("-Pzomboidforge.repository=" + Path.of(ZomboidForgeSettingsPluginTest.REPOSITORY).toUri());
|
||||
all.add("--stacktrace");
|
||||
|
||||
return GradleRunner.create().withProjectDir(this.project.toFile()).withPluginClasspath().withArguments(all).forwardOutput();
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildsAProjectOfOneFile() throws IOException
|
||||
{
|
||||
this.write("settings.gradle.kts", ZomboidForgeSettingsPluginTest.SETTINGS);
|
||||
|
||||
BuildResult result = this.runner("zomboidForgeSetup", "build", "--configuration-cache").build();
|
||||
|
||||
assertTrue(result.getOutput().contains("Created '.gitignore'."), result.getOutput());
|
||||
assertTrue(result.getOutput().contains("Mod 'shop' 1.0.0 passed the checks"), result.getOutput());
|
||||
assertTrue(Files.readString(this.project.resolve(".gitignore")).contains("build/"));
|
||||
assertTrue(Files.readString(this.project.resolve("src/main/java/com/example/shop/ShopMod.java")).contains("public final class ShopMod extends Mod"));
|
||||
assertTrue(Files.isRegularFile(this.project.resolve("build/distributions/shop-1.0.0.zip")), "the root project is named after the mod id");
|
||||
|
||||
BuildResult again = this.runner("zomboidForgeSetup", "build", "--configuration-cache").build();
|
||||
assertTrue(again.getOutput().contains("Configuration cache entry reused."), again.getOutput());
|
||||
assertFalse(again.getOutput().contains("Created '"), "existing files stay");
|
||||
}
|
||||
|
||||
@Test
|
||||
void setupKeepsExistingFiles() throws IOException
|
||||
{
|
||||
this.write("settings.gradle.kts", ZomboidForgeSettingsPluginTest.SETTINGS);
|
||||
this.write(".gitignore", "out/\n");
|
||||
this.write("src/main/java/com/example/shop/ShopMod.java", "// own\n");
|
||||
|
||||
BuildResult result = this.runner("zomboidForgeSetup").build();
|
||||
|
||||
assertFalse(result.getOutput().contains("Created '"), result.getOutput());
|
||||
assertEquals("out/\n", Files.readString(this.project.resolve(".gitignore")));
|
||||
assertEquals("// own\n", Files.readString(this.project.resolve("src/main/java/com/example/shop/ShopMod.java")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void setupCreatesAnEntryPointWithoutPackage() throws IOException
|
||||
{
|
||||
this.write("settings.gradle.kts", ZomboidForgeSettingsPluginTest.SETTINGS.replace("com.example.shop.ShopMod", "ShopMod"));
|
||||
|
||||
this.runner("zomboidForgeSetup", "compileJava").build();
|
||||
|
||||
String source = Files.readString(this.project.resolve("src/main/java/ShopMod.java"));
|
||||
assertTrue(source.startsWith("import dev.overlord.zomboidforge.api.Mod;"), source);
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildScriptSharesTheSettings() throws IOException
|
||||
{
|
||||
this.write("settings.gradle.kts", ZomboidForgeSettingsPluginTest.SETTINGS);
|
||||
this.write("build.gradle.kts", """
|
||||
zomboidForge {
|
||||
name = "Shop"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(files("libs/util.jar"))
|
||||
}
|
||||
""");
|
||||
Files.createDirectories(this.project.resolve("libs"));
|
||||
try (OutputStream file = Files.newOutputStream(this.project.resolve("libs/util.jar"))) { new JarOutputStream(file).close(); }
|
||||
|
||||
this.runner("zomboidForgeSetup", "modFolder", "-x", "checkMod").build();
|
||||
|
||||
assertTrue(Files.isRegularFile(this.project.resolve("build/mod/shop/lib/util.jar")));
|
||||
|
||||
try (JarFile jar = new JarFile(this.project.resolve("build/mod/shop/shop.jar").toFile()))
|
||||
{
|
||||
String toml = new String(jar.getInputStream(jar.getEntry("META-INF/zomboidforge/mod.toml")).readAllBytes(), StandardCharsets.UTF_8);
|
||||
|
||||
assertTrue(toml.contains("\"shop\""), toml);
|
||||
assertTrue(toml.contains("\"Shop\""), toml);
|
||||
}
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
package dev.overlord.zomboidforge.gradle;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/** Runs zomboidforge.jsh with JShell against build/repo and the wrapper of the repository root. */
|
||||
class ZomboidForgeUpdaterTest
|
||||
{
|
||||
private static final Path ROOT = Path.of(System.getProperty("zomboidforge.root"));
|
||||
private static final Path REPOSITORY = Path.of(System.getProperty("zomboidforge.testRepository"));
|
||||
private static final String VERSION = ZomboidForgeModPlugin.version();
|
||||
|
||||
@TempDir
|
||||
Path directory;
|
||||
|
||||
private record Run(int exit, String output) {}
|
||||
|
||||
/** A project of one settings.gradle.kts in {@code project/}, declaring {@code version}. */
|
||||
private Path project(String version) throws IOException
|
||||
{
|
||||
Path project = this.directory.resolve("project");
|
||||
Files.createDirectories(project);
|
||||
|
||||
Files.writeString(project.resolve("settings.gradle.kts"), """
|
||||
pluginManagement {
|
||||
repositories { maven("%s") }
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("dev.overlord.zomboidforge") version "%s"
|
||||
}
|
||||
|
||||
zomboidForge {
|
||||
id = "shop"
|
||||
version = "1.0.0"
|
||||
entrypoint = "com.example.shop.ShopMod"
|
||||
}
|
||||
""".formatted(ZomboidForgeUpdaterTest.REPOSITORY.toUri(), version));
|
||||
Files.writeString(project.resolve("gradle.properties"), "zomboidforge.repository=" + ZomboidForgeUpdaterTest.REPOSITORY.toUri() + "\n");
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
/** {@code files/v<version>/} with the wrapper of the repository root, as a release tag has it. */
|
||||
private Path files(String version) throws IOException
|
||||
{
|
||||
Path files = this.directory.resolve("files");
|
||||
|
||||
for (String path : List.of("gradlew", "gradlew.bat", "gradle/wrapper/gradle-wrapper.jar", "gradle/wrapper/gradle-wrapper.properties"))
|
||||
{
|
||||
Path target = files.resolve("v" + version).resolve(path);
|
||||
Files.createDirectories(target.getParent());
|
||||
Files.copy(ZomboidForgeUpdaterTest.ROOT.resolve(path), target);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
private Run run(Path project, Path repository, Path files, String... properties) throws Exception
|
||||
{
|
||||
Path jshell = Path.of(System.getProperty("java.home"), "bin", "jshell");
|
||||
List<String> command = new ArrayList<>(List.of(jshell.toString()));
|
||||
|
||||
command.add("-R-Dzomboidforge.repository=" + repository.toUri());
|
||||
command.add("-R-Dzomboidforge.files=" + files.toUri());
|
||||
for (String property : properties) command.add("-R-D" + property);
|
||||
command.add("-");
|
||||
|
||||
Process process = new ProcessBuilder(command)
|
||||
.directory(project.toFile())
|
||||
.redirectErrorStream(true)
|
||||
.redirectInput(ZomboidForgeUpdaterTest.ROOT.resolve("zomboidforge.jsh").toFile())
|
||||
.start();
|
||||
|
||||
String output = new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
|
||||
assertTrue(process.waitFor(5, TimeUnit.MINUTES), output);
|
||||
System.out.println(output);
|
||||
|
||||
return new Run(process.exitValue(), output);
|
||||
}
|
||||
|
||||
@Test
|
||||
void setsUpAndBuildsAProject() throws Exception
|
||||
{
|
||||
Path project = this.project("0.0.1");
|
||||
Run run = this.run(project, ZomboidForgeUpdaterTest.REPOSITORY, this.files(ZomboidForgeUpdaterTest.VERSION), "zomboidforge.version=" + ZomboidForgeUpdaterTest.VERSION);
|
||||
|
||||
assertEquals(0, run.exit(), run.output());
|
||||
assertTrue(run.output().contains("(was 0.0.1)"), run.output());
|
||||
assertTrue(run.output().contains("Created 'src/main/java/com/example/shop/ShopMod.java'."), run.output());
|
||||
assertTrue(Files.readString(project.resolve("settings.gradle.kts")).contains("version \"" + ZomboidForgeUpdaterTest.VERSION + "\""));
|
||||
assertTrue(Files.isExecutable(project.resolve("gradlew")));
|
||||
assertTrue(Files.isRegularFile(project.resolve("gradle/wrapper/gradle-wrapper.jar")));
|
||||
assertTrue(Files.isRegularFile(project.resolve("build/distributions/shop-1.0.0.zip")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void takesTheNewestVersionAndChangesNothingWhenADownloadFails() throws Exception
|
||||
{
|
||||
Path repository = this.directory.resolve("repository");
|
||||
Path metadata = repository.resolve("dev/overlord/zomboidforge/dev.overlord.zomboidforge.gradle.plugin/maven-metadata.xml");
|
||||
Files.createDirectories(metadata.getParent());
|
||||
Files.writeString(metadata, "<metadata><versioning><release>9.9.0</release><versions><version>0.1.0</version><version>9.9.0</version></versions></versioning></metadata>");
|
||||
|
||||
Path project = this.project("0.1.0");
|
||||
String settings = Files.readString(project.resolve("settings.gradle.kts"));
|
||||
Run run = this.run(project, repository, this.directory.resolve("files"));
|
||||
|
||||
assertEquals(1, run.exit(), run.output());
|
||||
assertTrue(run.output().contains("v9.9.0/gradlew"), run.output());
|
||||
assertEquals(settings, Files.readString(project.resolve("settings.gradle.kts")));
|
||||
assertTrue(Files.notExists(project.resolve("gradlew")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void failsForAVersionThatIsNotPublished() throws Exception
|
||||
{
|
||||
Path project = this.project("0.0.1");
|
||||
Run run = this.run(project, ZomboidForgeUpdaterTest.REPOSITORY, this.directory.resolve("files"), "zomboidforge.version=9.9.9");
|
||||
|
||||
assertEquals(1, run.exit(), run.output());
|
||||
assertTrue(run.output().contains("'9.9.9'"), run.output());
|
||||
}
|
||||
|
||||
@Test
|
||||
void failsWithoutThePluginInTheSettings() throws Exception
|
||||
{
|
||||
Path project = this.project("0.0.1");
|
||||
Files.writeString(project.resolve("settings.gradle.kts"), "rootProject.name = \"shop\"\n");
|
||||
|
||||
Run run = this.run(project, ZomboidForgeUpdaterTest.REPOSITORY, this.directory.resolve("files"));
|
||||
|
||||
assertEquals(1, run.exit(), run.output());
|
||||
assertTrue(run.output().contains("dev.overlord.zomboidforge"), run.output());
|
||||
}
|
||||
|
||||
@Test
|
||||
void failsWithoutSettings() throws Exception
|
||||
{
|
||||
Path project = this.directory.resolve("empty");
|
||||
Files.createDirectories(project);
|
||||
|
||||
Run run = this.run(project, ZomboidForgeUpdaterTest.REPOSITORY, this.directory.resolve("files"));
|
||||
|
||||
assertEquals(1, run.exit(), run.output());
|
||||
assertTrue(run.output().contains("settings.gradle.kts"), run.output());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user