Skip to content

Commit f0376d6

Browse files
authored
Create Eclipse launchers based off of Slime Launcher run configs (#1005)
These are very similar to the Eclipse run configurations generated by ForgeGradle 6. While generally still a work-in-progress in terms of resilience and feature set, they are functional and should work without issue as long as the consuming project doesn't use substitutions in resources. I'm still brainstorming ways to get around the fact that debugging JavaExec tasks is rather limited in Eclipse Buildship at the moment. I'll need to play around a bit more with bundled run XMLs for Eclipse, and see how the debugger treats those. - Bump embedded GradleUtils Shared to 3.3.38
1 parent 8b672e7 commit f0376d6

13 files changed

+686
-270
lines changed

settings.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ gradle.beforeProject { Project project ->
2020

2121
//@formatter:off
2222
dependencyResolutionManagement.versionCatalogs.register('libs') {
23-
version 'gradleutils', '3.3.21'
23+
version 'gradleutils', '3.3.38'
2424

2525
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
2626
plugin 'gradleutils', 'net.minecraftforge.gradleutils' versionRef 'gradleutils'
27-
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.1.6' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
28-
plugin 'changelog', 'net.minecraftforge.changelog' version '3.1.3' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
27+
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.1.7' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
28+
plugin 'changelog', 'net.minecraftforge.changelog' version '3.2.1' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
2929
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '2.0.0' // https://plugins.gradle.org/plugin/com.gradle.plugin-publish
30-
plugin 'shadow', 'com.gradleup.shadow' version '9.2.2' // https://plugins.gradle.org/plugin/com.gradleup.shadow
30+
plugin 'shadow', 'com.gradleup.shadow' version '9.3.0' // https://plugins.gradle.org/plugin/com.gradleup.shadow
3131

3232
// Static Analysis
3333
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2-1'

src/main/java/net/minecraftforge/gradle/SlimeLauncherOptions.java

Lines changed: 16 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -4,178 +4,53 @@
44
*/
55
package net.minecraftforge.gradle;
66

7+
import org.gradle.api.Action;
78
import org.gradle.api.Named;
89
import org.gradle.api.file.ConfigurableFileCollection;
910
import org.gradle.api.file.DirectoryProperty;
1011
import org.gradle.api.file.FileCollection;
11-
import org.gradle.api.provider.ListProperty;
12-
import org.gradle.api.provider.MapProperty;
13-
import org.gradle.api.provider.Property;
14-
import org.gradle.api.provider.Provider;
1512
import org.gradle.api.tasks.Classpath;
1613
import org.gradle.api.tasks.Input;
1714
import org.gradle.api.tasks.InputFiles;
1815
import org.gradle.api.tasks.Internal;
1916
import org.gradle.api.tasks.Optional;
17+
import org.gradle.api.tasks.SourceSet;
2018

21-
import java.util.Map;
22-
23-
/// The configuration options for Slime Launcher tasks.
24-
///
25-
/// The launch tasks generated by the [Minecraft][MinecraftExtension] extension are specialized
26-
/// [JavaExec][org.gradle.api.tasks.JavaExec] tasks that are designed to work with Slime Launcher, Minecraft Forge's
27-
/// dedicated launcher for the development environment. While the implementing task class remains internal (can still be
28-
/// configured as type `JavaExec`), these options exist to allow consumers to alter or add pre-defined attributes to the
29-
/// run configurations as needed.
30-
///
31-
/// For example, changing the [main class][org.gradle.api.tasks.JavaExec#getMainClass()] of the launch task as a
32-
/// `JavaExec` task will cause it to not use Slime Launcher and skip its configurations for it. If a consumer wishes to
33-
/// use Slime Launcher but change the main class it delegates to after initial setup, that can be done using
34-
/// [Property#set] on [#getMainClass()].
35-
public interface SlimeLauncherOptions extends Named {
19+
public interface SlimeLauncherOptions extends SlimeLauncherOptionsNested, Named {
3620
@Override
3721
@Input String getName();
3822

39-
/// The main class for Slime Launcher to use.
40-
///
41-
/// This is the class that will be invoked by Slime Launcher, **not** the main class of the
42-
/// [org.gradle.api.tasks.JavaExec] task that will be produced from these options.
43-
///
44-
/// @return A property for the main class
45-
@Input @Optional Property<String> getMainClass();
46-
47-
/// The arguments to pass to the main class.
48-
///
49-
/// This is the arguments that will be passed to the main class through Slime Launcher, **not** the arguments for
50-
/// Slime Launcher itself.
51-
///
52-
/// @return A property for the arguments to pass to the main class
53-
@Input @Optional ListProperty<String> getArgs();
23+
default void with(SourceSet sourceSet, Action<? super SlimeLauncherOptionsNested> action) {
24+
this.with(sourceSet.getName(), action);
25+
}
5426

55-
/// The JVM arguments to use.
56-
///
57-
/// These are applied immediately when Slime Launcher is executed. A reminder that Slime Launcher is not a
58-
/// re-launcher but a dev-environment bootstrapper.
59-
///
60-
/// @return A property for the JVM arguments
61-
@Input @Optional ListProperty<String> getJvmArgs();
27+
void with(String sourceSetName, Action<? super SlimeLauncherOptionsNested> action);
6228

6329
/// The classpath to use.
6430
///
65-
/// The classpath in question **must include** Slime Launcher in it. By default, the [minecraft][MinecraftExtension]
66-
/// extension adds Slime Launcher as a dependency to the consuming [project's][org.gradle.api.Project]
67-
/// [runtimeClasspath][org.gradle.api.plugins.JavaPlugin#RUNTIME_CLASSPATH_CONFIGURATION_NAME] configuration.
31+
/// The classpath in question **must include** Slime Launcher in it. By default, Slime Launcher is added on top of
32+
/// the [project's][org.gradle.api.Project]
33+
/// [runtimeClasspath][org.gradle.api.plugins.JavaPlugin#RUNTIME_CLASSPATH_CONFIGURATION_NAME] configuration for
34+
/// this task.
6835
///
69-
/// Keep in mind that if the [org.gradle.api.tasks.JavaExec] task is configured to have a different [main
70-
/// class][org.gradle.api.tasks.JavaExec#getMainClass()], the classpath does not need to include Slime Launcher.
36+
/// Keep in mind that if the [org.gradle.api.tasks.JavaExec] task is configured to have a different
37+
/// {@linkplain org.gradle.api.tasks.JavaExec#getMainClass() main class}, the classpath does not need to include
38+
/// Slime Launcher.
7139
///
7240
/// @return The classpath to use
7341
@InputFiles @Classpath @Optional ConfigurableFileCollection getClasspath();
7442

75-
/// The minimum memory heap size to use.
76-
///
77-
/// Working with this property is preferred over manually using the `-Xms` argument in the [JVM
78-
/// arguments][#getJvmArgs()].
79-
///
80-
/// @return A property for the minimum heap size
81-
@Input @Optional Property<String> getMinHeapSize();
82-
83-
/// The maximum memory heap size to use.
84-
///
85-
/// Working with this property is preferred over manually using the `-Xmx` argument in the [JVM
86-
/// arguments][#getJvmArgs()].
87-
///
88-
/// @return A property for the maximum heap size
89-
@Input @Optional Property<String> getMaxHeapSize();
90-
91-
/// The system properties to use.
92-
///
93-
/// @return A property for the system properties
94-
@Input @Optional MapProperty<String, String> getSystemProperties();
95-
96-
/// The environment variables to use.
97-
///
98-
/// @return A property for the environment variables
99-
@Input @Optional MapProperty<String, String> getEnvironment();
100-
10143
/// The working directory to use.
10244
///
103-
/// By default, this will be `run/`{@link #getName() name}.
45+
/// By default, this will be `run/`{@link SourceSet#getName() sourceSet}`/`{@link #getName() name}.
10446
///
10547
/// To clarify: this is the working directory of the Java process. Slime Launcher uses absolute file locations to
10648
/// place its caches and metadata, which do not interfere with the working directory.
10749
///
10850
/// @return A property for the working directory
51+
@Override
10952
@Internal DirectoryProperty getWorkingDir();
11053

111-
/// Adds to the arguments to pass to the [main class][#getMainClass()].
112-
///
113-
/// @param args The arguments to add
114-
/// @apiNote To add multiple arguments, use [#args(Object...)]
115-
/// @see #getArgs()
116-
void args(Object args);
117-
118-
/// Adds to the arguments to pass to the [main class][#getMainClass()].
119-
///
120-
/// @param args The arguments to add
121-
/// @apiNote Unlike [#setArgs(String...)], this method does not replace the existing arguments.
122-
/// @see #getArgs()
123-
void args(Object... args);
124-
125-
/// Adds to the arguments to pass to the [main class][#getMainClass()].
126-
///
127-
/// @param args The arguments to add
128-
/// @apiNote Unlike [ListProperty#set(Iterable)], this method does not replace the existing arguments.
129-
/// @see #getArgs()
130-
void args(Iterable<?> args);
131-
132-
/// Adds to the arguments to pass to the [main class][#getMainClass()].
133-
///
134-
/// @param args The arguments to add
135-
/// @apiNote Unlike [ListProperty#set(Provider)], this method does not replace the existing arguments.
136-
/// @see #getArgs()
137-
void args(Provider<? extends Iterable<?>> args);
138-
139-
/// Sets the arguments to pass to the [main class][#getMainClass()].
140-
///
141-
/// @param args The arguments
142-
/// @see #getArgs()
143-
void setArgs(String... args);
144-
145-
/// Adds to the JVM arguments to use.
146-
///
147-
/// @param jvmArgs The JVM argument to add
148-
/// @apiNote To add multiple arguments, use [#jvmArgs(Object...)]
149-
/// @see #getJvmArgs()
150-
void jvmArgs(Object jvmArgs);
151-
152-
/// Adds to the JVM arguments to use.
153-
///
154-
/// @param jvmArgs The JVM arguments to add
155-
/// @apiNote Unlike [#setJvmArgs(Object...)], this method does not replace the existing arguments.
156-
/// @see #getJvmArgs()
157-
void jvmArgs(Object... jvmArgs);
158-
159-
/// Adds to the JVM arguments to use.
160-
///
161-
/// @param jvmArgs The JVM arguments to add
162-
/// @apiNote Unlike [ListProperty#set(Iterable)], this method does not replace the existing arguments.
163-
/// @see #getJvmArgs()
164-
void jvmArgs(Iterable<?> jvmArgs);
165-
166-
/// Adds to the JVM arguments to use.
167-
///
168-
/// @param jvmArgs The JVM arguments to add
169-
/// @apiNote Unlike [ListProperty#set(Provider)], this method does not replace the existing arguments.
170-
/// @see #getJvmArgs()
171-
void jvmArgs(Provider<? extends Iterable<?>> jvmArgs);
172-
173-
/// Sets the JVM arguments to use.
174-
///
175-
/// @param jvmArgs The arguments
176-
/// @see ListProperty#set(Iterable)
177-
void setJvmArgs(Object... jvmArgs);
178-
17954
/// Adds to the classpath to use.
18055
///
18156
/// @param classpath The classpath to include with the existing classpath
@@ -229,52 +104,4 @@ default void setClasspath(Iterable<?> classpath) {
229104
default void setClasspath(FileCollection classpath) {
230105
this.getClasspath().setFrom(classpath);
231106
}
232-
233-
/// Adds a single system property to use.
234-
///
235-
/// @param name The name
236-
/// @param value The value
237-
/// @apiNote To add multiple system properties at once, use [#systemProperties(Provider)].
238-
/// @see #getSystemProperties()
239-
void systemProperty(String name, Object value);
240-
241-
/// Adds to the system properties to use.
242-
///
243-
/// @param properties The system properties
244-
/// @apiNote Unlike [MapProperty#set(Map)], this method does not replace the existing system properties. To add a
245-
/// single property, use [#systemProperty(String,Object)].
246-
/// @see #getSystemProperties()
247-
void systemProperties(Map<String, ?> properties);
248-
249-
/// Adds to the system properties to use.
250-
///
251-
/// @param properties The system properties
252-
/// @apiNote Unlike [MapProperty#set(Provider)], this method does not replace the existing system properties. To add
253-
/// a single property, use [#systemProperty(String,Object)].
254-
/// @see #getSystemProperties()
255-
void systemProperties(Provider<? extends Map<String, ?>> properties);
256-
257-
/// Adds a single environment variable to use.
258-
///
259-
/// @param name The name
260-
/// @param value The value
261-
/// @apiNote To add multiple environment variables at once, use [#environment(Provider)].
262-
/// @see #getEnvironment()
263-
void environment(String name, Object value);
264-
265-
/// Adds to the environment variables to use.
266-
///
267-
/// @param properties The environment variables
268-
/// @apiNote Unlike [MapProperty#set(Map)], this method does not replace the existing environment variables. To add
269-
/// a single variable, use [#environment(String,Object)].
270-
/// @see #getEnvironment()
271-
void environment(Map<String, ?> properties);
272-
273-
/// Adds to the environment variables to use.
274-
///
275-
/// @param properties The environment variables
276-
/// @apiNote Unlike [MapProperty#set(Provider)], this method does not replace the existing environment variables. To
277-
/// add a single variable, use [#environment(String,Object)].
278-
/// @see #getEnvironment()
279-
void environment(Provider<? extends Map<String, ?>> properties);
280107
}

0 commit comments

Comments
 (0)