2727import org .checkerframework .checker .nullness .qual .NonNull ;
2828import org .gradle .api .Action ;
2929import org .gradle .api .Named ;
30+ import org .gradle .api .Project ;
3031import org .gradle .api .file .ConfigurableFileCollection ;
3132import org .gradle .api .file .DirectoryProperty ;
3233import org .gradle .api .file .ProjectLayout ;
3839import org .gradle .api .tasks .Nested ;
3940import org .gradle .api .tasks .Optional ;
4041import org .gradle .api .tasks .SourceSet ;
42+ import org .gradle .api .tasks .SourceSetContainer ;
4143import org .gradle .jvm .toolchain .JavaLanguageVersion ;
4244import org .gradle .process .CommandLineArgumentProvider ;
4345import org .spongepowered .gradle .vanilla .internal .Constants ;
@@ -70,10 +72,11 @@ public class RunConfiguration implements Named {
7072 private final MapProperty <String , String > parameterTokens ;
7173 private final Property <Boolean > requiresAssetsAndNatives ;
7274 private final Property <SourceSet > ideaSourceSet ;
75+ private final Property <SourceSet > sourceSet ;
7376 private final Property <JavaLanguageVersion > targetVersion ;
7477
7578 @ Inject
76- public RunConfiguration (final String name , final ProjectLayout layout , final ObjectFactory objects ) {
79+ public RunConfiguration (final String name , final ProjectLayout layout , final ObjectFactory objects , final Project project ) {
7780 this .name = name ;
7881 this .displayName = objects .property (String .class );
7982
@@ -89,8 +92,12 @@ public RunConfiguration(final String name, final ProjectLayout layout, final Obj
8992 this .parameterTokens = objects .mapProperty (String .class , String .class );
9093 this .requiresAssetsAndNatives = objects .property (Boolean .class ).convention (false );
9194 this .ideaSourceSet = objects .property (SourceSet .class );
95+ this .sourceSet = objects .property (SourceSet .class )
96+ .convention (project .getExtensions ().getByType (SourceSetContainer .class ).named (SourceSet .MAIN_SOURCE_SET_NAME ));
9297 this .targetVersion = objects .property (JavaLanguageVersion .class );
9398
99+ this .classpath .from (this .sourceSet .map (SourceSet ::getOutput ), this .sourceSet .map (SourceSet ::getRuntimeClasspath ));
100+
94101 // Apply global environment here
95102 this .parameterTokens .put (ClientRunParameterTokens .LAUNCHER_NAME , Constants .NAME );
96103 this .parameterTokens .put (ClientRunParameterTokens .LAUNCHER_VERSION , Constants .VERSION );
@@ -156,13 +163,26 @@ public ConfigurableFileCollection getClasspath() {
156163 *
157164 * @return the source set to use
158165 * @since 0.2
166+ * @deprecated Use {@link #getSourceSet()} instead.
159167 */
168+ @ Deprecated
160169 @ Input
161170 @ Optional
162171 public Property <SourceSet > getIdeaRunSourceSet () {
163172 return this .ideaSourceSet ;
164173 }
165174
175+ /**
176+ * Get the source set to use in the classpath and IDE runs.
177+ *
178+ * @return the source set to use
179+ * @since 0.2.1
180+ */
181+ @ Input
182+ public Property <SourceSet > getSourceSet () {
183+ return this .sourceSet ;
184+ }
185+
166186 @ Nested
167187 public List <CommandLineArgumentProvider > getAllArgumentProviders () {
168188 return this .allArgs ;
0 commit comments