-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
185 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 71 additions & 5 deletions
76
src/main/java/net/neoforged/moddevgradle/internal/DownloadAssetsTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,95 @@ | ||
package net.neoforged.moddevgradle.internal; | ||
|
||
import org.gradle.api.GradleException; | ||
import org.gradle.api.file.RegularFileProperty; | ||
import org.gradle.api.provider.Property; | ||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.Optional; | ||
import org.gradle.api.tasks.OutputFile; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
import javax.inject.Inject; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Use the NFRT CLI to download the asset index and assets for the Minecraft version used by the | ||
* underlying NeoForge/NeoForm configuration. | ||
*/ | ||
abstract class DownloadAssetsTask extends NeoFormRuntimeEngineTask { | ||
abstract class DownloadAssetsTask extends NeoFormRuntimeTask { | ||
@Inject | ||
public DownloadAssetsTask() { | ||
} | ||
|
||
/** | ||
* Gradle dependency notation for the NeoForm data artifact, from which a Minecraft version will be derived. | ||
* <p> | ||
* To determine the minecraft version, the following properties will be checked in-order and the first one will be used: | ||
* <ol> | ||
* <li>{@link #getMinecraftVersion()}</li> | ||
* <li>{@link #getNeoFormArtifact()}</li> | ||
* <li>this property</li> | ||
* </ol> | ||
*/ | ||
@Input | ||
@Optional | ||
abstract Property<String> getNeoForgeArtifact(); | ||
|
||
/** | ||
* Gradle dependency notation for the NeoForm data artifact, from which a Minecraft version will be derived. | ||
* <p> | ||
* To determine the minecraft version, the following properties will be checked in-order and the first one will be used: | ||
* <ol> | ||
* <li>{@link #getMinecraftVersion()}</li> | ||
* <li>this property</li> | ||
* <li>{@link #getNeoForgeArtifact()}</li> | ||
* </ol> | ||
*/ | ||
@Input | ||
@Optional | ||
abstract Property<String> getNeoFormArtifact(); | ||
|
||
/** | ||
* The Minecraft version to download the assets for. | ||
* <p> | ||
* To determine the minecraft version, the following properties will be checked in-order and the first one will be used: | ||
* <ol> | ||
* <li>this property</li> | ||
* <li>{@link #getNeoFormArtifact()}</li> | ||
* <li>{@link #getNeoForgeArtifact()}</li> | ||
* </ol> | ||
*/ | ||
@Input | ||
@Optional | ||
abstract Property<String> getMinecraftVersion(); | ||
|
||
/** | ||
* A properties file will be written to this location which can be read by the runtime tasks | ||
* to determine where the asset index and asset root are located. | ||
*/ | ||
@OutputFile | ||
abstract RegularFileProperty getAssetPropertiesFile(); | ||
|
||
@TaskAction | ||
public void createArtifacts() { | ||
run(List.of( | ||
|
||
var args = new ArrayList<String>(); | ||
Collections.addAll(args, | ||
"download-assets", | ||
"--output-properties-to", getAssetPropertiesFile().get().getAsFile().getAbsolutePath() | ||
)); | ||
"--write-properties", getAssetPropertiesFile().get().getAsFile().getAbsolutePath() | ||
); | ||
|
||
// Only one should be specified, we try to use the best one. | ||
if (getMinecraftVersion().isPresent()) { | ||
Collections.addAll(args, "--minecraft-version", getMinecraftVersion().get()); | ||
} else if (getNeoFormArtifact().isPresent()) { | ||
Collections.addAll(args, "--neoform", getNeoFormArtifact().get()); | ||
} else if (getNeoForgeArtifact().isPresent()) { | ||
Collections.addAll(args, "--neoforge", getNeoForgeArtifact().get()); | ||
} else { | ||
throw new GradleException("One of minecraftVersion, neoFormArtifact or neoForgeArtifact must be specified to download assets."); | ||
} | ||
|
||
run(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 0 additions & 106 deletions
106
src/main/java/net/neoforged/moddevgradle/internal/NeoFormRuntimeEngineTask.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.