Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
java-version: '25'
- name: 'Build'
run: |
./gradlew \
Expand Down
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'org.moddingx'
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java.toolchain.languageVersion = JavaLanguageVersion.of(25)

repositories {
mavenCentral()
Expand All @@ -15,14 +15,14 @@ repositories {

dependencies {
api('jakarta.annotation:jakarta.annotation-api') { version { strictly '[3.0.0,)'; prefer '3.0.0' } }
api('net.neoforged:srgutils') { version { strictly '[1.0.9,)'; prefer '1.0.9' } }
api('net.neoforged.gradle:userdev') { version { strictly "[7.0.180,8.0.0)"; prefer '7.0.180' } }
api('org.moddingx:LauncherLib') { version { strictly '[2.1.0,2.2.0)'; prefer '2.1.0' } }
api('com.google.code.gson:gson') { version { strictly '[2.12.1,)'; prefer '2.12.1' } }
api('commons-io:commons-io') { version { strictly '[2.18.0,)'; prefer '2.18.0' } }
api('org.apache.maven:maven-repository-metadata') { version { strictly '[3.9.9,)'; prefer '3.9.9' } }
implementation('net.darkhax.curseforgegradle:CurseForgeGradle') { version { strictly '[1.1.26,)'; prefer '1.1.26' } }
implementation('com.modrinth.minotaur:Minotaur') { version { strictly '[2.8.7,)'; prefer '2.8.7' } }
api('net.neoforged:srgutils') { version { strictly '[1.0.11,)'; prefer '1.0.11' } }
api('net.neoforged.gradle:userdev') { version { strictly "[7.1.20,8.0.0)"; prefer '7.1.20' } }
api('org.moddingx:LauncherLib') { version { strictly '[2.2.0,2.3.0)'; prefer '2.1.0' } }
api('com.google.code.gson:gson') { version { strictly '[2.13.2,)'; prefer '2.13.2' } }
api('commons-io:commons-io') { version { strictly '[2.21.0,)'; prefer '2.21.0' } }
api('org.apache.maven:maven-repository-metadata') { version { strictly '[3.9.12,)'; prefer '3.9.12' } }
implementation('net.darkhax.curseforgegradle:CurseForgeGradle') { version { strictly '[1.1.28,)'; prefer '1.1.28' } }
implementation('com.modrinth.minotaur:Minotaur') { version { strictly '[2.8.10,)'; prefer '2.8.10' } }
}

gradlePlugin {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
50 changes: 32 additions & 18 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 22 additions & 18 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
import jakarta.annotation.Nonnull;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.process.ExecOperations;
import org.moddingx.modgradle.ModGradle;

public class MetaPlugin implements Plugin<Project> {
import javax.inject.Inject;

public abstract class MetaPlugin implements Plugin<Project> {

@Inject
public abstract ExecOperations getExecOperations();

@Override
public void apply(@Nonnull Project project) {
ModGradle.init(project);
this.setupRepositories(project);
project.getExtensions().create("mod", ModExtension.class, project);
project.getExtensions().create("mod", ModExtension.class, project, this.getExecOperations());
}

private void setupRepositories(Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.annotation.Nullable;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.process.ExecOperations;
import org.moddingx.launcherlib.util.LazyValue;
import org.moddingx.modgradle.plugins.meta.setup.ModBuildSetup;
import org.moddingx.modgradle.plugins.meta.delegate.ModConfig;
Expand All @@ -18,13 +19,15 @@
public class ModExtension extends GroovyObjectSupport {

private final Project project;
private final ExecOperations execOps;
private final ModPropertyAccess propertyAccess;

@Nullable
private Map<String, Object> properties;

public ModExtension(Project project) {
public ModExtension(Project project, ExecOperations execOps) {
this.project = project;
this.execOps = execOps;
this.properties = null;
this.propertyAccess = new ModPropertyAccess(this);
}
Expand All @@ -34,7 +37,7 @@ public void configure(@DelegatesTo(value = ModConfig.Delegate.class, strategy =
ModConfig config = ModConfig.configure(closure, new ModConfig(), ModConfig::delegate);
this.properties = new HashMap<>();
try {
ModBuildSetup.configureBuild(new ProjectContext(this.project, this.propertyAccess, this.properties::put, this::dependsOnProperties), config);
ModBuildSetup.configureBuild(new ProjectContext(this.project, this.execOps, this.propertyAccess, this.properties::put, this::dependsOnProperties), config);
} catch (RuntimeException e) {
throw new RuntimeException("Mod configuration failed.", e);
}
Expand Down Expand Up @@ -63,7 +66,7 @@ public boolean isCase(String propertyName) { // propertyName in this
}

private void dependsOnProperties(TaskProvider<?> taskProvider) {
this.project.afterEvaluate(p -> {
this.project.afterEvaluate(_ -> {
if (this.properties != null) {
taskProvider.configure(task -> {
if (this.project.getGroup() instanceof String group) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.annotation.Nullable;
import org.gradle.api.Project;
import org.gradle.api.tasks.SourceSet;
import org.gradle.process.ExecOperations;
import org.moddingx.launcherlib.util.LazyValue;
import org.moddingx.modgradle.ModGradle;
import org.moddingx.modgradle.plugins.meta.delegate.ModConfig;
Expand Down Expand Up @@ -38,15 +39,15 @@ public ModContext(ProjectContext context, ModConfig config) throws IOException {

this.modid = Objects.requireNonNull(config.modid, "modid not set.");
this.group = config.group != null ? config.group : this.project().getGroup().toString();
this.version = resolveVersion(this.project(), this.group, config.version);
this.version = resolveVersion(this.project(), this.execOperations(), this.group, config.version);
this.neoforge = Objects.requireNonNull(config.neoforge, "neoforge version not set.");
this.license = Objects.requireNonNull(config.license, "license not set.");
this.minecraft = config.minecraft != null ? config.minecraft : ModGradle.versions().neoforgeMinecraft(this.project(), this.neoforge);
this.java = config.java != 0 ? config.java : ModGradle.versions().java(this.minecraft);
this.resource = ModGradle.versions().resource(this.minecraft);
this.data = ModGradle.versions().data(this.minecraft);
this.timestamp = GitTimestampUtils.tryGetCommitTimestamp(this.project());
this.changelog = getChangelogProvider(this.project(), config.git.commitFormat, config.changelog);
this.timestamp = GitTimestampUtils.tryGetCommitTimestamp(this.project(), this.execOperations());
this.changelog = getChangelogProvider(this.project(), this.execOperations(), config.git.commitFormat, config.changelog);
this.additionalModSources = config.additionalModSources.stream().distinct().toList();

this.project().setGroup(this.group);
Expand All @@ -62,17 +63,17 @@ public ModContext(ProjectContext context, ModConfig config) throws IOException {
this.modProperty("changelog", this.changelog);
}

private static String resolveVersion(Project project, String group, ModVersionConfig delegate) throws IOException {
private static String resolveVersion(Project project, ExecOperations execOps, String group, ModVersionConfig delegate) throws IOException {
return switch (delegate.strategy) {
case ModVersionConfig.Strategy.Constant.INSTANCE -> delegate.base == null ? project.getVersion().toString() : delegate.base;
case ModVersionConfig.Strategy.Maven maven when delegate.base == null -> throw new IllegalStateException("Needs a base version to get version from a maven repository.");
case ModVersionConfig.Strategy.Maven _ when delegate.base == null -> throw new IllegalStateException("Needs a base version to get version from a maven repository.");
case ModVersionConfig.Strategy.Maven maven -> MavenVersionResolver.getVersion(project, maven.repository(), group, project.getName(), delegate.base);
case ModVersionConfig.Strategy.GitTag.INSTANCE -> GitTagVersionResolver.getVersion(project, delegate.base);
case ModVersionConfig.Strategy.GitTag.INSTANCE -> GitTagVersionResolver.getVersion(project, execOps, delegate.base);
};
}

private static LazyValue<String> getChangelogProvider(Project project, @Nullable String commitFormat, @Nullable Closure<String> customChangelog) throws IOException {
LazyValue<String> defaultChangelog = new LazyValue<>(() -> GitChangelogGenerator.generateChangelog(project, commitFormat));
private static LazyValue<String> getChangelogProvider(Project project, ExecOperations execOps, @Nullable String commitFormat, @Nullable Closure<String> customChangelog) {
LazyValue<String> defaultChangelog = new LazyValue<>(() -> GitChangelogGenerator.generateChangelog(project, execOps, commitFormat));
if (customChangelog == null) return defaultChangelog;
return new LazyValue<>(() -> {
ChangelogGenerationProperties properties = new ChangelogGenerationProperties(commitFormat, defaultChangelog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ public static void configureBuild(ModContext mod, ModMappingsConfig config) {
Subsystems subsystems = mod.project().getExtensions().getByType(Subsystems.class);
subsystems.parchment(parchment -> {
if (parchmentConfig.artifact() != null) {
parchment.enabled(true);
parchment.addRepository(true);
parchment.parchmentArtifact(parchmentConfig.artifact().getDescriptor());
} else {
String minecraftVersion = Objects.requireNonNullElse(parchmentConfig.minecraft(), mod.minecraft());
String parchmentVersion = parchmentConfig.version();
if (parchmentVersion == null) parchmentVersion = latestParchmentVersion(mod.project(), minecraftVersion, parchmentConfig.minecraft() == null);
if (parchmentVersion != null) {
parchment.enabled(true);
parchment.addRepository(true);
parchment.minecraftVersion(minecraftVersion);
parchment.mappingsVersion(parchmentVersion);
Expand Down
Loading