Skip to content

Commit

Permalink
Ship mixinextras-forge only in prod, use -common in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Jan 11, 2025
1 parent ffda8fa commit 2636070
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;

Expand Down Expand Up @@ -109,12 +108,8 @@ public final void dependencies(final String key, final NamedDomainObjectProvider
@Internal
public abstract SetProperty<ResolvedArtifactResult> getExcludedDependencies();

@Input
@Optional
protected abstract SetProperty<ModuleComponentIdentifier> getExcludedDependenciesBuildInput();

public final void excludedDependencies(final NamedDomainObjectProvider<Configuration> config) {
this.getExcludedDependencies().set(config.flatMap(conf -> conf.getIncoming().getArtifacts().getResolvedArtifacts()));
public final void excludeDependencies(final NamedDomainObjectProvider<Configuration> config) {
this.getExcludedDependencies().addAll(config.flatMap(conf -> conf.getIncoming().getArtifacts().getResolvedArtifacts()));
}

/**
Expand All @@ -128,13 +123,6 @@ public final void excludedDependencies(final NamedDomainObjectProvider<Configura

public OutputDependenciesToJson() {
this.getAllowedClassifiers().add("");
this.getExcludedDependenciesBuildInput().set(this.getExcludedDependencies().map(deps -> {
return deps.stream()
.map(res -> res.getId().getComponentIdentifier())
.filter(res -> res instanceof ModuleComponentIdentifier)
.map(res -> (ModuleComponentIdentifier) res)
.collect(Collectors.toSet());
}));
}

@TaskAction
Expand Down Expand Up @@ -219,19 +207,9 @@ public ConfigurationHolder(final Configuration configuration) {
this.configuration = configuration.getIncoming().getArtifacts().getResolvedArtifacts();
}

@Input
public Provider<Set<String>> getIds() {
return this.getArtifacts().map(set -> set.stream()
.map(art -> art.getId().getComponentIdentifier())
.filter(id -> id instanceof ModuleComponentIdentifier)
.map(ComponentIdentifier::getDisplayName)
.collect(Collectors.toSet()));
}

@Internal
public Provider<Set<ResolvedArtifactResult>> getArtifacts() {
return this.configuration;
}
}

}
19 changes: 16 additions & 3 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ val gameManagedLibrariesConfig: NamedDomainObjectProvider<Configuration> = confi
val serviceShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("serviceShadedLibraries")
val gameShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("gameShadedLibraries")

val excludedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("excludedLibraries") {
extendsFrom(gameShadedLibrariesConfig.get())
}
val includedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("includedLibraries") {
extendsFrom(gameManagedLibrariesConfig.get())
}

val runTaskOnlyConfig: NamedDomainObjectProvider<Configuration> = configurations.register("runTaskOnly")

configurations.named("forgeRuntimeLibrary") {
Expand Down Expand Up @@ -222,7 +229,7 @@ dependencies {
game(libs.javaxInject)
game(platform(apiLibs.adventure.bom))
game(libs.adventure.serializerConfigurate4)
game(libs.mixinextras.forge)
game(libs.mixinextras.common)

val serviceShadedLibraries = serviceShadedLibrariesConfig.name
serviceShadedLibraries(project(transformersProject.path)) { isTransitive = false }
Expand All @@ -236,6 +243,12 @@ dependencies {
spongeImpl.copyModulesExcludingProvided(gameLibrariesConfig.get(), serviceLayerConfig.get(), gameManagedLibrariesConfig.get())
}

val excluded = excludedLibrariesConfig.name
excluded(libs.mixinextras.common) // dev only

val included = includedLibrariesConfig.name
included(libs.mixinextras.forge) // prod only

val runTaskOnly = runTaskOnlyConfig.name
// Arch-loom bug, fix support of MOD_CLASSES
runTaskOnly("net.minecraftforge:bootstrap-dev:2.1.3")
Expand Down Expand Up @@ -344,8 +357,8 @@ tasks {

val emitDependencies by registering(org.spongepowered.gradle.impl.OutputDependenciesToJson::class) {
group = "sponge"
this.dependencies("main", gameManagedLibrariesConfig)
this.excludedDependencies(gameShadedLibrariesConfig)
this.dependencies("main", includedLibrariesConfig)
this.excludeDependencies(excludedLibrariesConfig)

outputFile.set(installerResources.map { it.file("sponge-libraries.json") })
}
Expand Down
2 changes: 1 addition & 1 deletion neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ tasks {
val emitDependencies by registering(org.spongepowered.gradle.impl.OutputDependenciesToJson::class) {
group = "sponge"
this.dependencies("main", gameManagedLibrariesConfig)
this.excludedDependencies(gameShadedLibrariesConfig)
this.excludeDependencies(gameShadedLibrariesConfig)

outputFile.set(installerResources.map { it.file("sponge-libraries.json") })
}
Expand Down
8 changes: 2 additions & 6 deletions vanilla/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,12 @@ tasks {
val installerResources = project.layout.buildDirectory.dir("generated/resources/installer")
vanillaInstaller.resources.srcDir(installerResources)

val downloadNotNeeded = configurations.register("downloadNotNeeded") {
extendsFrom(configurations.minecraft.get())
extendsFrom(gameShadedLibrariesConfig.get())
}

val emitDependencies by registering(org.spongepowered.gradle.impl.OutputDependenciesToJson::class) {
group = "sponge"
this.dependencies("bootstrap", bootLibrariesConfig)
this.dependencies("main", gameManagedLibrariesConfig)
this.excludedDependencies(downloadNotNeeded)
this.excludeDependencies(configurations.minecraft)
this.excludeDependencies(gameShadedLibrariesConfig)

outputFile.set(installerResources.map { it.file("sponge-libraries.json") })
}
Expand Down

0 comments on commit 2636070

Please sign in to comment.