Skip to content

Commit

Permalink
Fix lazy run resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans committed Sep 5, 2024
1 parent e1a8016 commit 815c414
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public abstract class RunImpl implements ConfigurableDSLElement<Run>, Run {

private final Project project;
private final String name;
private final ListProperty<RunSpecification> rawSpecifications;
private final ListProperty<RunSpecification> specifications;
private final RunSourceSets modSources;
private final RunSourceSets unitTestSources;
Expand Down Expand Up @@ -68,7 +69,10 @@ public RunImpl(final Project project, final String name) {
this.environmentVariables = this.project.getObjects().mapProperty(String.class, String.class);
this.programArguments = this.project.getObjects().listProperty(String.class);
this.systemProperties = this.project.getObjects().mapProperty(String.class, String.class);

this.rawSpecifications = this.project.getObjects().listProperty(RunSpecification.class);
this.specifications = this.project.getObjects().listProperty(RunSpecification.class);
this.specifications.addAll(rawSpecifications);

getIsSingleInstance().convention(true);
getIsClient().convention(false);
Expand Down Expand Up @@ -265,13 +269,13 @@ public Provider<Set<FileSystemLocation>> getSdkClasspathElements() {
@Override
public void runType(@NotNull String name) {
getConfigureFromTypeWithName().set(false); // Don't re-configure
specifications.addAll(getRunTypesByName(name));
rawSpecifications.addAll(getRunTypesByName(name));
}

@Override
public void run(@NotNull String name) {
getConfigureFromTypeWithName().set(false); // Don't re-configure
specifications.addAll(getRunByName(name));
rawSpecifications.addAll(getRunByName(name));
}

@Override
Expand All @@ -289,13 +293,12 @@ public final void configure() {
}

private void potentiallyAddRunTemplateFromType() {
List<RunType> runTypes = specifications.map(l -> l.stream().filter(RunType.class::isInstance).map(RunType.class::cast).toList()).get();

specifications.addAll(
runTypes.stream()
.map(RunType::getRunTemplate)
.filter(Objects::nonNull)
.toList());
rawSpecifications.map(l -> l.stream().filter(RunType.class::isInstance).map(RunType.class::cast)
.map(RunType::getRunTemplate)
.filter(Objects::nonNull)
.toList())
);
}

private void configureFromRuns() {
Expand Down Expand Up @@ -508,7 +511,7 @@ private void configureFromSDKs() {

private void potentiallyAddRunTypeByName() {
if (getConfigureFromTypeWithName().get()) {
specifications.addAll(getRunTypesByName(name));
rawSpecifications.addAll(getRunTypesByName(name));
}
}

Expand Down Expand Up @@ -592,19 +595,19 @@ public final void configure(final @NotNull String name) {
);

getConfigureFromTypeWithName().set(false); // Don't re-configure
specifications.addAll(getRunTypesByName(name));
rawSpecifications.addAll(getRunTypesByName(name));
}

@Override
public final void configure(final @NotNull RunSpecification runType) {
getConfigureFromTypeWithName().set(false); // Don't re-configure
this.specifications.add(project.provider(() -> runType));
this.rawSpecifications.add(project.provider(() -> runType));
}

@Override
public void configure(@NotNull Provider<? extends RunSpecification> typeProvider) {
getConfigureFromTypeWithName().set(false); // Don't re-configure
this.specifications.add(typeProvider);
this.rawSpecifications.add(typeProvider);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ class RunTests extends BuilderBasedTestSpecification {
it.tasks(':runData')
//We are expecting this test to fail, since there is a mod without any files included so it is fine.
it.shouldFail()
it.stacktrace()
it.debug()
}

then:
Expand Down

0 comments on commit 815c414

Please sign in to comment.