|
4 | 4 | */ |
5 | 5 | package net.minecraftforge.gradle; |
6 | 6 |
|
| 7 | +import org.gradle.api.Action; |
7 | 8 | import org.gradle.api.Named; |
8 | 9 | import org.gradle.api.file.ConfigurableFileCollection; |
9 | 10 | import org.gradle.api.file.DirectoryProperty; |
10 | 11 | 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; |
15 | 12 | import org.gradle.api.tasks.Classpath; |
16 | 13 | import org.gradle.api.tasks.Input; |
17 | 14 | import org.gradle.api.tasks.InputFiles; |
18 | 15 | import org.gradle.api.tasks.Internal; |
19 | 16 | import org.gradle.api.tasks.Optional; |
| 17 | +import org.gradle.api.tasks.SourceSet; |
20 | 18 |
|
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 { |
36 | 20 | @Override |
37 | 21 | @Input String getName(); |
38 | 22 |
|
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 | + } |
54 | 26 |
|
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); |
62 | 28 |
|
63 | 29 | /// The classpath to use. |
64 | 30 | /// |
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. |
68 | 35 | /// |
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. |
71 | 39 | /// |
72 | 40 | /// @return The classpath to use |
73 | 41 | @InputFiles @Classpath @Optional ConfigurableFileCollection getClasspath(); |
74 | 42 |
|
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 | | - |
101 | 43 | /// The working directory to use. |
102 | 44 | /// |
103 | | - /// By default, this will be `run/`{@link #getName() name}. |
| 45 | + /// By default, this will be `run/`{@link SourceSet#getName() sourceSet}`/`{@link #getName() name}. |
104 | 46 | /// |
105 | 47 | /// To clarify: this is the working directory of the Java process. Slime Launcher uses absolute file locations to |
106 | 48 | /// place its caches and metadata, which do not interfere with the working directory. |
107 | 49 | /// |
108 | 50 | /// @return A property for the working directory |
| 51 | + @Override |
109 | 52 | @Internal DirectoryProperty getWorkingDir(); |
110 | 53 |
|
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 | | - |
179 | 54 | /// Adds to the classpath to use. |
180 | 55 | /// |
181 | 56 | /// @param classpath The classpath to include with the existing classpath |
@@ -229,52 +104,4 @@ default void setClasspath(Iterable<?> classpath) { |
229 | 104 | default void setClasspath(FileCollection classpath) { |
230 | 105 | this.getClasspath().setFrom(classpath); |
231 | 106 | } |
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); |
280 | 107 | } |
0 commit comments