Skip to content

Commit

Permalink
Fix extending the client/datagen compile/runtime classpath from main (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 authored Oct 22, 2023
1 parent 39841d8 commit 7106441
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.plugins.JavaPlugin;
Expand Down Expand Up @@ -142,15 +143,16 @@ public void configureDataGeneration(Action<DataGenerationSettings> action) {
sourceSets.create(DATAGEN_SOURCESET_NAME, sourceSet -> {
sourceSet.setCompileClasspath(
sourceSet.getCompileClasspath()
.plus(mainSourceSet.getCompileClasspath())
.plus(mainSourceSet.getOutput())
);

sourceSet.setRuntimeClasspath(
sourceSet.getRuntimeClasspath()
.plus(mainSourceSet.getRuntimeClasspath())
.plus(mainSourceSet.getOutput())
);

extendsFrom(getProject(), sourceSet.getCompileClasspathConfigurationName(), mainSourceSet.getCompileClasspathConfigurationName());
extendsFrom(getProject(), sourceSet.getRuntimeClasspathConfigurationName(), mainSourceSet.getRuntimeClasspathConfigurationName());
});

extension.getMods().create(settings.getModId().get(), mod -> {
Expand Down Expand Up @@ -298,4 +300,12 @@ private static class PomNotFoundException extends Exception {
super(cause);
}
}

private static void extendsFrom(Project project, String name, String extendsFrom) {
final ConfigurationContainer configurations = project.getConfigurations();

configurations.named(name, configuration -> {
configuration.extendsFrom(configurations.getByName(extendsFrom));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,16 @@ private void evaluate(Project project) {

clientOnlySourceSet.setCompileClasspath(
clientOnlySourceSet.getCompileClasspath()
.plus(mainSourceSet.getCompileClasspath())
.plus(mainSourceSet.getOutput())
);
clientOnlySourceSet.setRuntimeClasspath(
clientOnlySourceSet.getRuntimeClasspath()
.plus(mainSourceSet.getRuntimeClasspath())
.plus(mainSourceSet.getOutput())
);

extendsFrom(project, clientOnlySourceSet.getCompileClasspathConfigurationName(), mainSourceSet.getCompileClasspathConfigurationName());
extendsFrom(project, clientOnlySourceSet.getRuntimeClasspathConfigurationName(), mainSourceSet.getRuntimeClasspathConfigurationName());

RemapConfigurations.configureClientConfigurations(project, clientOnlySourceSet);

// Include the client only output in the jars
Expand Down

0 comments on commit 7106441

Please sign in to comment.