Skip to content

Commit

Permalink
Add an option (false by default) to validate ATs (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt authored Jun 28, 2024
1 parent 91b6650 commit 22a4a11
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ plugins {
neoForge {
// We currently only support NeoForge versions later than 21.0.x
// See https://projects.neoforged.net/neoforged/neoforge for the latest updates
version = "21.0.0-beta"
version = "21.0.42-beta"
// Validate AT files and raise errors when they have invalid targets
// This option is false by default, but turning it on is recommended
validateAccessTransformers = true
runs {
client {
Expand Down Expand Up @@ -377,7 +381,7 @@ configurations.all {
```groovy
neoForge {
neoFormRuntime {
// Use specific NFRT version
// Use a specific NFRT version
// Gradle Property: neoForge.neoFormRuntime.version
version = "1.2.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public NeoForgeExtension(Project project) {

return List.of();
}));
getValidateAccessTransformers().convention(false);
}

/**
Expand Down Expand Up @@ -91,6 +92,13 @@ public void addModdingDependenciesTo(SourceSet sourceSet) {
*/
public abstract ListProperty<String> getAccessTransformers();

/**
* Enable access transformer validation, raising fatal errors if an AT targets a member that doesn't exist.
* <p>
* <b>Default</b> {@code false}<br>
*/
public abstract Property<Boolean> getValidateAccessTransformers();

public NamedDomainObjectContainer<ModModel> getMods() {
return mods;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* the Minecraft artifacts for compiling and mods.
*/
public abstract class NeoFormRuntime {
private static final String DEFAULT_NFRT_VERSION = "0.1.58";
private static final String DEFAULT_NFRT_VERSION = "0.1.63";

@Inject
public NeoFormRuntime(Project project) {
Expand Down Expand Up @@ -65,5 +65,4 @@ public NeoFormRuntime(Project project) {
* <b>Gradle property:</b> {@code neoForge.neoFormRuntime.analyzeCacheMisses}.
*/
public abstract Property<Boolean> getAnalyzeCacheMisses();

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.gradle.work.DisableCachingByDefault;
Expand All @@ -27,6 +28,10 @@ public CreateMinecraftArtifactsTask() {
@InputFiles
abstract ConfigurableFileCollection getAccessTransformers();

@Input
@Optional
abstract Property<Boolean> getValidateAccessTransformers();

@Input
abstract Property<Boolean> getParchmentEnabled();

Expand Down Expand Up @@ -61,6 +66,9 @@ public void createArtifacts() {
args.add("--access-transformer");
args.add(accessTransformer.getAbsolutePath());
}
if (getValidateAccessTransformers().getOrElse(false)) {
args.add("--validate-access-transformers");
}

if (getParchmentEnabled().get()) {
var parchmentData = getParchmentData().getFiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public void apply(Project project) {
task.setDescription("Creates the NeoForge and Minecraft artifacts by invoking NFRT.");

task.getAccessTransformers().from(accessTransformers);
task.getValidateAccessTransformers().set(extension.getValidateAccessTransformers());
task.getParchmentData().from(parchmentData);
task.getParchmentEnabled().set(parchment.getEnabled());
task.getParchmentConflictResolutionPrefix().set(parchment.getConflictResolutionPrefix());
Expand Down
2 changes: 1 addition & 1 deletion testproject/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
org.gradle.configuration-cache=true

# Dependency versions
neoforge_version=21.0.37-beta
neoforge_version=21.0.42-beta

0 comments on commit 22a4a11

Please sign in to comment.