Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Early configuration #3121

Merged
merged 4 commits into from
Aug 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 49 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,27 @@ tasks {
}
from(launch.get().output)
}
val prelaunchJar by registering(Jar::class) {
getArchiveClassifier().set("prelaunch")
manifest {
attributes(mapOf(
"Specification-Title" to "SpongeCommon",
"Specification-Vendor" to "SpongePowered",
"Specification-Version" to apiProject.version,
"Implementation-Title" to project.name,
"Implementation-Version" to generateImplementationVersionString(apiProject.version as String, minecraftVersion, recommendedVersion),
"Implementation-Vendor" to "SpongePowered"
// "Implementation-Timestamp" to Instant.now().format("yyyy-MM-dd'T'HH:mm:ssZ")
))
}
from(prelaunch.get().output)
}

reobf {
create("mixinsJar")
create("accessorsJar")
create("launchJar")
// TODO: does prelaunch need to be here? it has no reference to obf classes
}

}
Expand All @@ -128,26 +144,38 @@ version = generateImplementationVersionString(apiProject.version as String, mine
// Configurations
val minecraftConfig by configurations.named("minecraft")

val prelaunchConfig by configurations.register("preLaunch")

val launchConfig by configurations.register("launch") {
extendsFrom(minecraftConfig)
extendsFrom(prelaunchConfig)
}
val accessorsConfig by configurations.register("accessors") {
extendsFrom(minecraftConfig)
extendsFrom(launchConfig)
}
val mixinsConfig by configurations.register("mixins") {
extendsFrom(prelaunchConfig)
extendsFrom(launchConfig)
extendsFrom(minecraftConfig)
}
val modlauncherConfig by configurations.register("modlauncher") {
extendsFrom(prelaunchConfig)
extendsFrom(launchConfig)
extendsFrom(minecraftConfig)
}

// create the sourcesets
val main by sourceSets

val prelaunch by sourceSets.registering {
applyNamedDependencyOnOutput(originProject = project, sourceAdding = this, targetSource = main, implProject = project, dependencyConfigName = main.implementationConfigurationName)
project.dependencies {
mixinsConfig([email protected])
}
}
val launch by sourceSets.registering {
applyNamedDependencyOnOutput(originProject = project, sourceAdding = prelaunch.get(), targetSource = this, implProject = project, dependencyConfigName = this.implementationConfigurationName)
project.dependencies {
mixinsConfig([email protected])
}
Expand All @@ -163,6 +191,7 @@ val accessors by sourceSets.registering {
}
val mixins by sourceSets.registering {
applyNamedDependencyOnOutput(originProject = project, sourceAdding = launch.get(), targetSource = this, implProject = project, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = project, sourceAdding = prelaunch.get(), targetSource = this, implProject = project, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = project, sourceAdding = accessors.get(), targetSource = this, implProject = project, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = project, sourceAdding = main, targetSource = this, implProject = project, dependencyConfigName = this.implementationConfigurationName)
}
Expand Down Expand Up @@ -212,13 +241,17 @@ dependencies {
launchConfig("com.google.code.gson:gson:2.8.0")
launchConfig("org.ow2.asm:asm-tree:6.2")
launchConfig("org.ow2.asm:asm-util:6.2")
launchConfig("org.apache.logging.log4j:log4j-api:2.11.2")
launchConfig("org.spongepowered:configurate-core:3.7.1")
launchConfig("org.spongepowered:configurate-hocon:3.7.1")
launchConfig("org.spongepowered:configurate-json:3.7.1")
launchConfig("org.apache.logging.log4j:log4j-core:2.11.2")
add(launch.get().implementationConfigurationName, launchConfig)

// Prelaunch -- initialization that needs to occur without game access
prelaunchConfig("org.spongepowered:plugin-spi:0.1.1-SNAPSHOT")
prelaunchConfig("org.apache.logging.log4j:log4j-api:2.11.2")
prelaunchConfig("org.spongepowered:configurate-core:3.7.1")
prelaunchConfig("org.spongepowered:configurate-hocon:3.7.1")
prelaunchConfig("org.spongepowered:configurate-json:3.7.1")
prelaunchConfig("org.apache.logging.log4j:log4j-core:2.11.2")
add(prelaunch.get().implementationConfigurationName, prelaunchConfig)

// Annotation Processor
"accessorsAnnotationProcessor"("org.spongepowered:mixin:$mixinVersion:processor")
"mixinsAnnotationProcessor"("org.spongepowered:mixin:$mixinVersion:processor")
Expand Down Expand Up @@ -399,16 +432,19 @@ project("SpongeVanilla") {
// implementation (compile) dependencies
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = accessors.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
}
val vanillaLaunch by sourceSets.register("launch") {
// implementation (compile) dependencies
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = main, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = this, targetSource = vanillaMain, implProject = vanillaProject, dependencyConfigName = vanillaMain.implementationConfigurationName)
}
val vanillaAccessors by sourceSets.register("accessors") {
// implementation (compile) dependencies
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = accessors.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = this, targetSource = vanillaMain, implProject = vanillaProject, dependencyConfigName = vanillaMain.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = vanillaLaunch, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
Expand All @@ -419,6 +455,7 @@ project("SpongeVanilla") {
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = accessors.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = vanillaAccessors, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = main, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = vanillaMain, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = vanillaLaunch, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
Expand All @@ -427,6 +464,7 @@ project("SpongeVanilla") {
// implementation (compile) dependencies
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = vanillaLaunch, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = vanillaProject, dependencyConfigName = this.implementationConfigurationName)
// runtime dependencies - literally add the rest of the project, because we want to launch the game
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = vanillaMixins, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.runtimeConfigurationName)
applyNamedDependencyOnOutput(originProject = vanillaProject, sourceAdding = vanillaAccessors, targetSource = this, implProject = vanillaProject, dependencyConfigName = this.runtimeConfigurationName)
Expand Down Expand Up @@ -642,6 +680,7 @@ project("SpongeVanilla") {
from(commonProject.tasks.getByName("mixinsJar"))
from(commonProject.tasks.getByName("accessorsJar"))
from(commonProject.tasks.getByName("launchJar"))
from(commonProject.tasks.getByName("prelaunchJar"))
from(jar)
from(vanillaLaunchJar)
from(vanillaModLauncherJar)
Expand Down Expand Up @@ -670,6 +709,7 @@ project("SpongeVanilla") {
from(commonProject.tasks.getByName("mixinsJar"))
from(commonProject.tasks.getByName("accessorsJar"))
from(commonProject.tasks.getByName("launchJar"))
from(commonProject.tasks.getByName("prelaunchJar"))
from(jar)
from(vanillaLaunchJar)
from(vanillaModLauncherJar)
Expand Down Expand Up @@ -769,16 +809,19 @@ if (spongeForge != null) {
// implementation (compile) dependencies
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = accessors.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
}
val forgeLaunch by sourceSets.register("launch") {
// implementation (compile) dependencies
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = main, targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = forgeProject, sourceAdding = this, targetSource = forgeMain, implProject = forgeProject, dependencyConfigName = forgeMain.implementationConfigurationName)
}
val forgeAccessors by sourceSets.register("accessors") {
// implementation (compile) dependencies
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = accessors.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = forgeProject, sourceAdding = this, targetSource = forgeMain, implProject = forgeProject, dependencyConfigName = forgeMain.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = forgeProject, sourceAdding = forgeLaunch, targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
Expand All @@ -789,6 +832,7 @@ if (spongeForge != null) {
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = accessors.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = forgeProject, sourceAdding = forgeAccessors, targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = launch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = prelaunch.get(), targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = commonProject, sourceAdding = main, targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = forgeProject, sourceAdding = forgeMain, targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
applyNamedDependencyOnOutput(originProject = forgeProject, sourceAdding = forgeLaunch, targetSource = this, implProject = forgeProject, dependencyConfigName = this.implementationConfigurationName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.MixinEnvironment;
import org.spongepowered.common.launch.plugin.DummyPluginContainer;
import org.spongepowered.common.launch.plugin.loader.PluginEngine;
import org.spongepowered.common.plugin.loader.PluginEngine;
import org.spongepowered.common.launch.plugin.SpongePluginManager;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.PluginKeys;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/spongepowered/common/SpongeCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.util.Direction;
import org.spongepowered.common.config.InheritableConfigHandle;
import org.spongepowered.common.config.SpongeConfigs;
import org.spongepowered.common.config.core.InheritableConfigHandle;
import org.spongepowered.common.config.core.SpongeConfigs;
import org.spongepowered.common.config.inheritable.GlobalConfig;
import org.spongepowered.common.launch.Launcher;
import org.spongepowered.common.registry.SpongeGameRegistry;
Expand All @@ -45,6 +45,7 @@

import javax.annotation.Nullable;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

@Singleton
Expand Down Expand Up @@ -106,7 +107,7 @@ public static Path getGameDirectory() {
}

public static Path getPluginConfigDirectory() {
return SpongeCommon.getGameDirectory().resolve(SpongeConfigs.getCommon().get().getGeneral().configDir());
return Paths.get(SpongeConfigs.getCommon().get().getGeneral().configDir());
}

public static Path getSpongeConfigDirectory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import org.spongepowered.api.world.SerializationBehavior;
import org.spongepowered.common.config.InheritableConfigHandle;
import org.spongepowered.common.config.core.InheritableConfigHandle;
import org.spongepowered.common.config.inheritable.WorldConfig;
import org.spongepowered.common.world.dimension.SpongeDimensionType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
import org.spongepowered.common.command.registrar.SpongeParameterizedCommandRegistrar;
import org.spongepowered.common.command.registrar.tree.builder.RootCommandTreeNode;
import org.spongepowered.common.command.sponge.SpongeCommand;
import org.spongepowered.common.config.SpongeConfigs;
import org.spongepowered.common.config.core.SpongeConfigs;
import org.spongepowered.common.event.ShouldFire;
import org.spongepowered.common.event.lifecycle.RegisterCommandEventImpl;
import org.spongepowered.common.event.tracking.PhaseTracker;
Expand Down
Loading