1616import org .gradle .api .provider .Property ;
1717import org .gradle .api .provider .Provider ;
1818import org .gradle .api .provider .ProviderFactory ;
19-
2019import javax .inject .Inject ;
2120import java .util .ArrayList ;
2221import java .util .HashMap ;
@@ -27,7 +26,9 @@ public abstract class SlimeLauncherOptionsImpl implements SlimeLauncherOptionsIn
2726 private final String name ;
2827
2928 private final Property <String > mainClass = this .getObjects ().property (String .class );
29+ private final Property <Boolean > inheritArgs = this .getObjects ().property (Boolean .class );
3030 private final ListProperty <String > args = this .getObjects ().listProperty (String .class );
31+ private final Property <Boolean > inheritJvmArgs = this .getObjects ().property (Boolean .class );
3132 private final ListProperty <String > jvmArgs = this .getObjects ().listProperty (String .class );
3233 private final ConfigurableFileCollection classpath = this .getObjects ().fileCollection ();
3334 private final Property <String > minHeapSize = this .getObjects ().property (String .class );
@@ -61,11 +62,21 @@ public Property<String> getMainClass() {
6162 return this .mainClass ;
6263 }
6364
65+ @ Override
66+ public Property <Boolean > getInheritArgs () {
67+ return this .inheritArgs ;
68+ }
69+
6470 @ Override
6571 public ListProperty <String > getArgs () {
6672 return this .args ;
6773 }
6874
75+ @ Override
76+ public Property <Boolean > getInheritJvmArgs () {
77+ return this .inheritJvmArgs ;
78+ }
79+
6980 @ Override
7081 public ListProperty <String > getJvmArgs () {
7182 return this .jvmArgs ;
@@ -263,7 +274,9 @@ public void environment(Provider<? extends Map<String, ?>> properties) {
263274 public SlimeLauncherOptionsInternal inherit (Map <String , RunConfig > configs , String sourceSetName , String name ) {
264275 var target = getObjects ().newInstance (SlimeLauncherOptionsImpl .class , name );
265276 target .getMainClass ().convention (this .getMainClass ());
277+ target .getInheritArgs ().convention (this .getInheritArgs ());
266278 target .getArgs ().convention (this .getArgs ());
279+ target .getInheritJvmArgs ().convention (this .getInheritJvmArgs ());
267280 target .getJvmArgs ().convention (this .getJvmArgs ());
268281 target .getClasspath ().convention (this .getClasspath ());
269282 target .getMinHeapSize ().convention (this .getMinHeapSize ());
@@ -284,11 +297,21 @@ private SlimeLauncherOptionsInternal inherit(SlimeLauncherOptionsInternal target
284297 if (config .main != null )
285298 target .getMainClass ().convention (config .main );
286299
287- if (config .args != null && !config .args .isEmpty ())
288- target .getArgs ().convention (List .copyOf (config .args ));
300+ if (config .args != null && !config .args .isEmpty ()) {
301+ if (target .getInheritArgs ().getOrElse (Boolean .TRUE )) {
302+ var args = new ArrayList <>(config .args );
303+ args .addAll (target .getArgs ().get ());
304+ target .getArgs ().convention (args );
305+ }
306+ }
289307
290- if (config .jvmArgs != null && !config .jvmArgs .isEmpty ())
291- target .jvmArgs (config .jvmArgs );
308+ if (config .jvmArgs != null && !config .jvmArgs .isEmpty ()) {
309+ if (target .getInheritJvmArgs ().getOrElse (Boolean .TRUE )) {
310+ var args = new ArrayList <>(config .jvmArgs );
311+ args .addAll (target .getJvmArgs ().get ());
312+ target .getJvmArgs ().convention (args );
313+ }
314+ }
292315
293316 target .getClient ().convention (config .client );
294317
0 commit comments