66
77import net .minecraftforge .util .download .DownloadUtils ;
88import net .minecraftforge .util .hash .HashStore ;
9- import org .gradle .api .artifacts .Configuration ;
109import org .gradle .api .artifacts .ModuleVersionIdentifier ;
1110import org .gradle .api .file .ConfigurableFileCollection ;
1211import org .gradle .api .file .Directory ;
@@ -88,12 +87,13 @@ public Tool.Resolved get(Provider<? extends Directory> cachesDir, ProviderFactor
8887
8988 FileCollection classpathFromGradle = toolsExt .getObjects ().fileCollection ();
9089 var classpathFromDownload = definition .getClasspath ();
90+ var mainClass = definition .getMainClass ().orElse (providers .provider (this ::getMainClass )).getOrNull ();
9191
9292 if (classpathFromDownload .isEmpty ()) {
9393 var overrides = fillOverrides (definition );
9494 classpathFromGradle = toolsExt .getProject ().getConfigurations ().detachedConfiguration (
9595 toolsExt .getDependencies ().create (overrides .artifact )
96- );
96+ ). setTransitive ( mainClass != null ) ;
9797 classpathFromDownload = toolsExt .getObjects ().fileCollection ().from (
9898 providers .of (Source .class , spec -> spec .parameters (parameters -> {
9999 parameters .getInputFile ().set (cachesDir .map (d -> d .file ("tools/" + overrides .fileName )));
@@ -106,7 +106,7 @@ public Tool.Resolved get(Provider<? extends Directory> cachesDir, ProviderFactor
106106 toolsExt .getObjects (),
107107 classpathFromGradle ,
108108 classpathFromDownload ,
109- definition . getMainClass (). orElse ( providers . provider ( this :: getMainClass )) ,
109+ mainClass ,
110110 definition .getJavaLauncher ().orElse (providers .provider (() -> SharedUtil .launcherForStrictly (toolsExt .getJavaToolchains (), this .getJavaVersion ()).get ()))
111111 );
112112 }
@@ -161,15 +161,15 @@ public Property<String> getArtifact() {
161161 final class ResolvedImpl implements ToolInternal .Resolved {
162162 private final FileCollection classpathFromGradle ;
163163 private final FileCollection classpathFromDownload ;
164- private final Property < String > mainClass ;
164+ private final @ Nullable String mainClass ;
165165 private final Property <JavaLauncher > javaLauncher ;
166166
167167 private @ Nullable Boolean useGradle = null ;
168168
169- private ResolvedImpl (ObjectFactory objects , FileCollection classpathFromGradle , FileCollection classpathFromDownload , Provider <? extends String > mainClass , Provider <? extends JavaLauncher > javaLauncher ) {
169+ private ResolvedImpl (ObjectFactory objects , FileCollection classpathFromGradle , FileCollection classpathFromDownload , @ Nullable String mainClass , Provider <? extends JavaLauncher > javaLauncher ) {
170170 this .classpathFromGradle = classpathFromGradle ;
171171 this .classpathFromDownload = classpathFromDownload ;
172- this .mainClass = objects . property ( String . class ). value ( mainClass ) ;
172+ this .mainClass = mainClass ;
173173 this .javaLauncher = objects .property (JavaLauncher .class ).value (javaLauncher );
174174 }
175175
@@ -208,7 +208,7 @@ public int getJavaVersion() {
208208
209209 @ Override
210210 public @ Nullable String getMainClass () {
211- return this .mainClass . getOrNull () ;
211+ return this .mainClass ;
212212 }
213213 }
214214
0 commit comments