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
7 changes: 2 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ dependencies {
// GradleUtils Shared Base
implementation libs.gradleutils.shared

// AccessTransformers
compileOnlyApi libs.accesstransformers.gradle

// Utils
implementation libs.maven.artifact
implementation libs.bundles.utils
Expand Down Expand Up @@ -100,8 +97,8 @@ tasks.named('shadowJar', ShadowJar) {
}
}

tasks.withType(Javadoc).configureEach {
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(24) }
tasks.named('javadoc', Javadoc) {
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(25) }
}

changelog {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ abstract class ForgeGradlePluginEntry implements Plugin<PluginAware> {
private static final GradleVersion CURRENT_GRADLE = GradleVersion.current();
private static final GradleVersion MINIMUM_GRADLE = GradleVersion.version("9.3.0-rc-1");

private static final String PLUGIN_DISPLAY_NAME = "ForgeGradle";
private static final String PLUGIN_VERSION = "7";
private static final String PLUGIN_CLASS = "net.minecraftforge.gradle.internal.ForgeGradlePlugin";

@Inject
public ForgeGradlePluginEntry() { }

@Override
public void apply(PluginAware target) {
if (CURRENT_GRADLE.compareTo(MINIMUM_GRADLE) < 0) {
String message = String.format(
"ForgeGradle 7 requires %s or later to run. You are currently using %s.",
"%s %s requires %s or later to run. You are currently using %s.",
PLUGIN_DISPLAY_NAME,
PLUGIN_VERSION,
MINIMUM_GRADLE,
CURRENT_GRADLE
);
Expand All @@ -37,9 +43,9 @@ public void apply(PluginAware target) {
}

try {
target.getPluginManager().apply(Class.forName("net.minecraftforge.gradle.internal.ForgeGradlePlugin"));
target.getPluginManager().apply(Class.forName(PLUGIN_CLASS));
} catch (ClassNotFoundException e) {
throw new RuntimeException("Failed to find the ForgeGradle entry-point.", e);
throw new RuntimeException(String.format("Failed to find the %s entry-point.", PLUGIN_DISPLAY_NAME), e);
}
}
}
6 changes: 1 addition & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gradle.beforeProject { Project project ->

//@formatter:off
dependencyResolutionManagement.versionCatalogs.register('libs') {
version 'gradleutils', '3.3.40'
version 'gradleutils', '3.3.42'

plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
plugin 'gradleutils', 'net.minecraftforge.gradleutils' versionRef 'gradleutils'
Expand All @@ -45,10 +45,6 @@ dependencyResolutionManagement.versionCatalogs.register('libs') {
// GradleUtils Shared Base
library 'gradleutils-shared', 'net.minecraftforge', 'gradleutils-shared' versionRef 'gradleutils'

// AccessTransformers Gradle Plugin
// https://plugins.gradle.org/plugin/net.minecraftforge.accesstransformers
library 'accesstransformers-gradle', 'net.minecraftforge.accesstransformers', 'net.minecraftforge.accesstransformers.gradle.plugin' version '5.0.1'

// Artifact Versioning
library 'maven-artifact', 'org.apache.maven', 'maven-artifact' version '3.9.11'

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/net/minecraftforge/gradle/ClosureOwner.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,4 @@ public interface ClosureOwner {
///
/// @see ClosureOwner
interface MinecraftDependency extends ClosureOwner, net.minecraftforge.gradle.MinecraftDependency, ExternalModuleDependency { }

/// A closure owner that delegates to [net.minecraftforge.gradle.MinecraftDependencyWithAccessTransformers] and
/// [ExternalModuleDependency].
///
/// @see ClosureOwner
interface MinecraftDependencyWithAccessTransformers extends ClosureOwner, net.minecraftforge.gradle.MinecraftDependencyWithAccessTransformers, ExternalModuleDependency { }
}
45 changes: 45 additions & 0 deletions src/main/java/net/minecraftforge/gradle/ForgeGradleExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import groovy.lang.Closure;
import org.gradle.api.Action;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.attributes.Attribute;

/// The ForgeGradle extension contains a handful of helpers that are not directly related to development involving
/// Minecraft.
Expand Down Expand Up @@ -44,4 +45,48 @@ public interface ForgeGradleExtension {
* @return The closure
*/
Action<MavenArtifactRepository> getMinecraftLibsMaven();

/**
* The attributes object for easy reference.
* <pre><code>
* dependencies {
* implementation 'com.example:example:1.0' {
* attributes.attribute(fg.attributes.os, 'windows')
* }
* }
* </code></pre>
*
* @return The attributes object
* @see Attributes
*/
Attributes getAttributes();

/// This interface contains the attributes used by the [Minecraft][MinecraftExtension] extension for resolving the
/// Minecraft and deobfuscated dependencies.
///
/// @see ForgeGradleExtension#getAttributes()
interface Attributes {
/// The operating system of the project's host.
///
/// This is used to filter natives from the Minecraft repo.
///
/// @return The operating system attribute
Attribute<String> getOs();

/// The requested mappings channel of the project.
///
/// This is determined using [MinecraftMappings#getChannel()] via [MinecraftMappingsContainer#getMappings()]
///
/// @return The mappings channel attribute
/// @see #getMappingsVersion()
Attribute<String> getMappingsChannel();

/// The requested mappings version of the project.
///
/// This is determined using [MinecraftMappings#getVersion()] via [MinecraftMappingsContainer#getMappings()]
///
/// @return The mappings channel version
/// @see #getMappingsChannel()
Attribute<String> getMappingsVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
*/
package net.minecraftforge.gradle;

import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.RegularFileProperty;

/// An extension of [MinecraftDependency] that contains additional convenience methods for working with
/// AccessTransformers.
///
/// @see MinecraftDependency
public interface MinecraftDependencyWithAccessTransformers extends MinecraftDependency {
public interface MinecraftAccessTransformersContainer {
/// The default path, from the source set's [resources][org.gradle.api.tasks.SourceSet#getResources()], for the
/// AccessTransformers config to be located in.
String DEFAULT_PATH = "META-INF/accesstransformer.cfg";

/// Gets the AccessTransformer configuration to use.
///
/// @return The property for the configuration file to use
RegularFileProperty getAccessTransformer();
ConfigurableFileCollection getAccessTransformer();

/// Sets the path, relative to this dependency's [org.gradle.api.tasks.SourceSet#getResources()], to the
/// AccessTransformers config file to use.
Expand All @@ -35,8 +32,7 @@ public interface MinecraftDependencyWithAccessTransformers extends MinecraftDepe
/// file is in a strict location.
void setAccessTransformer(String accessTransformer);

/// Sets if this dependency should use AccessTransformers. The default value depends on the state of
/// [MinecraftExtensionForProjectWithAccessTransformers#getAccessTransformers()].
/// Sets if this dependency should use AccessTransformers.
///
/// If `true`, this calls [#setAccessTransformer(String)] using [#DEFAULT_PATH] as the path. If `false`, this will
/// force this dependency to *not use* AccessTransformers, even if the convention is set to do so from the Minecraft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/// The Minecraft dependency contains information essential for how the
/// {@linkplain MinecraftExtensionForProject minecraft extension} processes Minecraft dependencies.
public interface MinecraftDependency extends MinecraftMappingsContainer {
public interface MinecraftDependency extends MinecraftMappingsContainer, MinecraftAccessTransformersContainer {
/// The collection of Slime Launcher options with which to create the launcher tasks.
///
/// @return The collection of run task options
Expand Down
45 changes: 0 additions & 45 deletions src/main/java/net/minecraftforge/gradle/MinecraftExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.gradle.api.Action;
import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.attributes.Attribute;

/// The main extension for ForgeGradle, where the Minecraft dependency resolution takes place.
///
Expand Down Expand Up @@ -56,48 +55,4 @@ default MavenArtifactRepository mavenizer(RepositoryHandler repositories) {
repositories.addFirst(mavenizer);
return mavenizer;
}

/**
* The attributes object for easy reference.
* <pre><code>
* dependencies {
* implementation 'com.example:example:1.0' {
* attributes.attribute(minecraft.attributes.os, 'windows')
* }
* }
* </code></pre>
*
* @return The attributes object
* @see Attributes
*/
Attributes getAttributes();

/// This interface contains the attributes used by the [Minecraft][MinecraftExtension] extension for resolving the
/// Minecraft and deobfuscated dependencies.
///
/// @see MinecraftExtension#getAttributes()
interface Attributes {
/// The operating system of the project's host.
///
/// This is used to filter natives from the Minecraft repo.
///
/// @return The operating system attribute
Attribute<String> getOs();

/// The requested mappings channel of the project.
///
/// This is determined using [MinecraftMappings#getChannel()] via [#getMappings()]
///
/// @return The mappings channel attribute
/// @see #getMappingsVersion()
Attribute<String> getMappingsChannel();

/// The requested mappings version of the project.
///
/// This is determined using [MinecraftMappings#getVersion()] via [#getMappings()]
///
/// @return The mappings channel version
/// @see #getMappingsChannel()
Attribute<String> getMappingsVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import groovy.lang.DelegatesTo;
import groovy.transform.stc.ClosureParams;
import groovy.transform.stc.FromString;
import groovy.transform.stc.SimpleType;
import net.minecraftforge.gradleutils.shared.Closures;
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
Expand All @@ -16,32 +17,8 @@
/// [Project][org.gradle.api.Project]-specific additions for the Minecraft extension. These will be accessible from the
/// `minecraft` DSL object within your project's buildscript.
///
/// @param <T> The type of closure owner used for [#dependency]
/// @see MinecraftExtension
public interface MinecraftExtensionForProject<T extends ClosureOwner> extends MinecraftExtension {
/// The collection of Slime Launcher options with which to create the launcher tasks.
///
/// @return The collection of run task options
NamedDomainObjectContainer<? extends SlimeLauncherOptions> getRuns();

/// Configures the Slime Launcher options for this project, which will be used to create the launcher tasks.
///
/// @param closure The configuring closure
default void runs(
@DelegatesTo(NamedDomainObjectContainer.class)
@ClosureParams(value = FromString.class, options = "org.gradle.api.NamedDomainObjectContainer<net.minecraftforge.gradle.SlimeLauncherOptions>")
Closure<?> closure
) {
this.getRuns().configure(closure);
}

/// Configures the Slime Launcher options for this project, which will be used to create the launcher tasks.
///
/// @param action The configuring action
default void runs(Action<? super NamedDomainObjectContainer<? extends SlimeLauncherOptions>> action) {
this.runs(Closures.action(this, action));
}

public interface MinecraftExtensionForProject extends MinecraftExtension, MinecraftDependency {
/// Creates (or marks if existing) the given dependency as a Minecraft dependency and configures it with the given
/// closure.
///
Expand All @@ -53,7 +30,7 @@ default void runs(Action<? super NamedDomainObjectContainer<? extends SlimeLaunc
ExternalModuleDependency dependency(
Object value,
@DelegatesTo(ExternalModuleDependency.class)
@ClosureParams(value = FromString.class, options = "T")
@ClosureParams(value = SimpleType.class, options = "net.minecraftforge.gradle.ClosureOwner.MinecraftDependency")
Closure<?> closure
);

Expand All @@ -65,7 +42,7 @@ ExternalModuleDependency dependency(
/// @return The dependency
/// @see <a href="https://docs.gradle.org/current/userguide/declaring_dependencies.html">Declaring Dependencies
/// in Gradle</a>
default ExternalModuleDependency dependency(Object value, Action<? super T> action) {
default ExternalModuleDependency dependency(Object value, Action<? super ClosureOwner.MinecraftDependency> action) {
return this.dependency(value, Closures.action(this, action));
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface MinecraftMappings extends Serializable {
/// @return The channel
String getChannel();

/// Gets the version for these mappings (i.e. `1.21.10`)
/// Gets the version for these mappings (i.e. `1.21.11`)
///
/// @return The version
String getVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface MinecraftMappingsContainer {
* <p>This method includes a generated named variant that can make declaration in your buildscript easier.</p>
* <pre><code>
* minecraft {
* mappings channel: 'official', version: '1.21.5'
* mappings channel: 'official', version: '1.21.11'
* }
* </code></pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,4 @@ static class MinecraftDependencyImpl extends ClosureOwnerImpl<net.minecraftforge
super(originalOwner, ownerDelegate);
}
}

static class MinecraftDependencyWithAccessTransformersImpl extends ClosureOwnerImpl<net.minecraftforge.gradle.MinecraftDependencyWithAccessTransformers> implements ClosureOwnerInternal.MinecraftDependencyWithAccessTransformers {
MinecraftDependencyWithAccessTransformersImpl(Object originalOwner, net.minecraftforge.gradle.MinecraftDependencyWithAccessTransformers ownerDelegate) {
super(originalOwner, ownerDelegate);
}
}
}
Loading