Skip to content

Commit

Permalink
[FIX]: Fix parchment detection (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans authored Aug 14, 2024
1 parent 714f31d commit cd10dca
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public WithPropertyLookup(Project project) {
}

protected Provider<String> getStringProperty(String propertyName, String defaultValue) {
return this.project.getProviders().gradleProperty(SUBSYSTEM_PROPERTY_PREFIX + propertyName)
.orElse(defaultValue);
final Provider<String> property = this.project.getProviders().gradleProperty(SUBSYSTEM_PROPERTY_PREFIX + propertyName);
if (defaultValue == null)
return property;

return property.orElse(defaultValue);
}

protected Provider<Directory> getDirectoryProperty(String propertyName, Provider<Directory> defaultValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,25 @@ public ParchmentExtensions(Project project) {
super(project, "parchment");

getParchmentArtifact().convention(
getStringLocalProperty("parchmentArtifact", "").orElse(
getStringLocalProperty("parchmentArtifact", null).orElse(
getMinecraftVersion()
.zip(getMappingsVersion(), (minecraftVersion, mappingVersion) -> {
return DEFAULT_PARCHMENT_GROUP
+ ":" + DEFAULT_PARCHMENT_ARTIFACT_PREFIX + minecraftVersion
+ ":" + mappingVersion
+ "@zip";
})
}).orElse("")
)
);
getConflictPrefix().convention("p_");
getMinecraftVersion().convention(
getStringProperty("minecraftVersion", null)
getStringLocalProperty("minecraftVersion", null)
);
getMappingsVersion().convention(
getStringProperty("mappingsVersion", null)
getStringLocalProperty("mappingsVersion", null)
);
getAddRepository().convention(
getBooleanProperty("addRepository", true, false)
getBooleanLocalProperty("addRepository", true)
);
getIsEnabled().set(getParchmentArtifact()
.map(s -> !s.isEmpty()).orElse(getBooleanLocalProperty("enabled", true))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.neoforged.gradle.userdev

import net.neoforged.trainingwheels.gradle.functional.BuilderBasedTestSpecification
import org.gradle.testkit.runner.TaskOutcome

class ParchmentTests extends BuilderBasedTestSpecification {

@Override
protected void configurePluginUnderTest() {
pluginUnderTest = "net.neoforged.gradle.neoform";
injectIntoAllProject = true;
}

def "parchment can be used"() {
given:
def project = create("parchment_can_be_used", {
it.property("neogradle.subsystems.parchment.minecraftVersion", "1.21")
it.property("neogradle.subsystems.parchment.mappingsVersion", "2024.07.28")
it.build("""
plugins {
id 'net.neoforged.gradle.userdev'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
dependencies {
implementation 'net.neoforged:neoforge:+'
}
""")
it.file("src/main/java/net/neoforged/gradle/userdev/ConfigurationCacheTests.java", """
package net.neoforged.gradle.userdev;
import net.minecraft.client.Minecraft;
public class ConfigurationCacheTests {
public static void main(String[] args) {
System.out.println(Minecraft.getInstance().getClass().toString());
}
}
""")
it.withToolchains()
it.withGlobalCacheDirectory(tempDir)
})

when:
def run = project.run {
it.tasks('compileJava')
it.arguments('--warning-mode', 'fail', '--stacktrace')
}

then:
run.task(':compileJava').outcome == TaskOutcome.SUCCESS
run.task(':neoFormApplyParchment').outcome == TaskOutcome.SUCCESS
}
}

0 comments on commit cd10dca

Please sign in to comment.