diff --git a/README.md b/README.md index 55c3699..279034e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ This produces the Vanilla artifacts in build/ | `--dist` [required] | Which distribution type to generate artifacts for. NeoForm defines these and usually `client`, `server` and `joined` are available. | | `--neoforge=` | Pass the NeoForge artifact to use as `net.neoforged:neoforge:`. When passing this, the NeoForm version is implied. It can still be overridden by passing `--neoform` as well. | | `--neoform=` | Pass the NeoForm artifact to use as `net.neoforged:neoform:@zip`. | +| `--neoform-file=` | As an alternative to `--neoform` you can also pass a path to the NeoForm data archive directly. | | `--write-result=:` | This option can be passed multiple times. It tells NFRT to write a result of the execution graph to the given path, such as the recompiled Minecraft jar-file, or the sources. If you pass no such option, NFRT will print which results are available. | | `--access-transformer=` | Adds access transformers which will be applied to the source before recompiling it. | | `--interface-injection-data=` | Adds [interface injection data](https://github.com/neoforged/JavaSourceTransformer?tab=readme-ov-file#interface-injection) which will be applied to the source before recompiling it. | diff --git a/src/main/java/net/neoforged/neoform/runtime/cli/Main.java b/src/main/java/net/neoforged/neoform/runtime/cli/Main.java index d9806d9..d2f42d8 100644 --- a/src/main/java/net/neoforged/neoform/runtime/cli/Main.java +++ b/src/main/java/net/neoforged/neoform/runtime/cli/Main.java @@ -21,7 +21,7 @@ import static picocli.CommandLine.Option; import static picocli.CommandLine.ScopeType; -@Command(name = "neoform-runtime", subcommands = {RunNeoFormCommand.class, DownloadAssetsCommand.class, CleanCacheCommand.class, CacheMaintenance.class}, mixinStandardHelpOptions = true) +@Command(name = "neoform-runtime", subcommands = {CommandLine.HelpCommand.class, RunNeoFormCommand.class, DownloadAssetsCommand.class, CleanCacheCommand.class, CacheMaintenance.class}, mixinStandardHelpOptions = true) public class Main { @Option(names = "--home-dir", scope = ScopeType.INHERIT, description = "Where NFRT should store caches.") Path homeDir = getDefaultHomeDir(); diff --git a/src/main/java/net/neoforged/neoform/runtime/cli/RunNeoFormCommand.java b/src/main/java/net/neoforged/neoform/runtime/cli/RunNeoFormCommand.java index 043bd60..1082265 100644 --- a/src/main/java/net/neoforged/neoform/runtime/cli/RunNeoFormCommand.java +++ b/src/main/java/net/neoforged/neoform/runtime/cli/RunNeoFormCommand.java @@ -69,12 +69,19 @@ public class RunNeoFormCommand extends NeoFormEngineCommand { String parchmentConflictPrefix; static class SourceArtifacts { - @CommandLine.Option(names = "--neoform") - String neoform; + @CommandLine.ArgGroup(multiplicity = "1") + NeoFormArtifact neoform; @CommandLine.Option(names = "--neoforge") String neoforge; } + static class NeoFormArtifact { + @CommandLine.Option(names = "--neoform") + String artifact; + @CommandLine.Option(names = "--neoform-file") + Path file; + } + @Override protected void runWithNeoFormEngine(NeoFormEngine engine, List closables) throws IOException, InterruptedException { var artifactManager = engine.getArtifactManager(); @@ -83,11 +90,17 @@ protected void runWithNeoFormEngine(NeoFormEngine engine, List cl var neoforgeArtifact = artifactManager.get(sourceArtifacts.neoforge); var neoforgeZipFile = engine.addManagedResource(new JarFile(neoforgeArtifact.path().toFile())); var neoforgeConfig = NeoForgeConfig.from(neoforgeZipFile); - var neoformArtifact = MavenCoordinate.parse(neoforgeConfig.neoformArtifact()); - // Allow it to be overridden - if (sourceArtifacts.neoform != null) { - LOG.println("Overriding NeoForm version " + neoformArtifact + " with CLI argument " + sourceArtifacts.neoform); - neoformArtifact = MavenCoordinate.parse(sourceArtifacts.neoform); + + // Allow it to be overridden with local or remote data + Path neoformArtifact; + if (sourceArtifacts.neoform.file != null) { + LOG.println("Overriding NeoForm version " + neoforgeConfig.neoformArtifact() + " with NeoForm file " + sourceArtifacts.neoform.file); + neoformArtifact = sourceArtifacts.neoform.file; + } else if (sourceArtifacts.neoform.artifact != null) { + LOG.println("Overriding NeoForm version " + neoforgeConfig.neoformArtifact() + " with CLI argument " + sourceArtifacts.neoform.artifact); + neoformArtifact = artifactManager.get(MavenCoordinate.parse(sourceArtifacts.neoform.artifact)).path(); + } else { + neoformArtifact = artifactManager.get(MavenCoordinate.parse(neoforgeConfig.neoformArtifact())).path(); } engine.loadNeoFormData(neoformArtifact, dist); @@ -168,7 +181,14 @@ protected void runWithNeoFormEngine(NeoFormEngine engine, List cl createSourcesAndCompiledWithNeoForge(engine.getGraph(), compiledWithNeoForgeOutput, sourcesWithNeoForgeOutput); } else { - engine.loadNeoFormData(MavenCoordinate.parse(sourceArtifacts.neoform), dist); + Path neoFormDataPath; + if (sourceArtifacts.neoform.file != null) { + neoFormDataPath = sourceArtifacts.neoform.file; + } else { + neoFormDataPath = artifactManager.get(MavenCoordinate.parse(sourceArtifacts.neoform.artifact)).path(); + } + + engine.loadNeoFormData(neoFormDataPath, dist); } if (!additionalAccessTransformers.isEmpty()) { diff --git a/src/main/java/net/neoforged/neoform/runtime/engine/NeoFormEngine.java b/src/main/java/net/neoforged/neoform/runtime/engine/NeoFormEngine.java index eed280f..b54d085 100644 --- a/src/main/java/net/neoforged/neoform/runtime/engine/NeoFormEngine.java +++ b/src/main/java/net/neoforged/neoform/runtime/engine/NeoFormEngine.java @@ -153,9 +153,8 @@ public void addDataSource(String id, ZipFile zipFile, String sourceFolder) { dataSources.put(id, new DataSource(zipFile, sourceFolder)); } - public void loadNeoFormData(MavenCoordinate neoFormArtifactId, String dist) throws IOException { - var neoFormArchive = artifactManager.get(Objects.requireNonNull(neoFormArtifactId, "neoFormArtifactId")); - var zipFile = new ZipFile(neoFormArchive.path().toFile()); + public void loadNeoFormData(Path neoFormDataPath, String dist) throws IOException { + var zipFile = new ZipFile(neoFormDataPath.toFile()); var config = NeoFormConfig.from(zipFile); var distConfig = config.getDistConfig(dist);