diff --git a/README.md b/README.md index b972f7589..c3cd79eb9 100644 --- a/README.md +++ b/README.md @@ -368,6 +368,7 @@ More information on the relevant tool, its released version and documentation ca ## DevLogin The DevLogin tool is a tool that allows you to log in to a Minecraft account without having to use the Minecraft launcher, during development. +By default, it will use the credentials stored by the vanilla launcher, however if you are not logged in there, it will offer you the ability to log in directly from the console. This tool is used by the runs subsystem to enable logged in plays on all client runs. The tool can be configured using the following properties: ```properties @@ -391,6 +392,12 @@ By default, the dev login tool is disabled, and can only be enabled for client r > [!WARNING] > If you enable the dev login tool for a non-client run, you will get an error message. +If you want to enable the dev login tool for all client runs, you can set the following property in your gradle.properties: +```properties +neogradle.subsystems.devLogin.conventionForRun=true +``` +This will enable the dev login tool for all client runs, unless explicitly disabled. + ### Configurations To add the dev login tool to your run we create a custom configuration to which we add the dev login tool. This configuration is created for the first source-set you register with the run as a mod source set. diff --git a/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java b/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java index c117454e5..c67e0babe 100644 --- a/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java +++ b/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java @@ -43,6 +43,9 @@ private void configureDevLoginDefaults() { devLogin.getConfigurationSuffix().convention( getStringProperty("devLogin.configurationSuffix").orElse("DevLoginLocalOnly") ); + devLogin.getConventionForRun().convention( + getBooleanProperty("devLogin.conventionForRun").orElse(false) + ); } private void configureToolsDefaults() { diff --git a/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java b/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java index 6cef7aeef..122b9c138 100644 --- a/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java +++ b/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java @@ -4,6 +4,7 @@ import com.google.common.collect.Sets; import net.minecraftforge.gdi.ConfigurableDSLElement; import net.neoforged.gradle.common.util.constants.RunsConstants; +import net.neoforged.gradle.dsl.common.extensions.subsystems.Subsystems; import net.neoforged.gradle.dsl.common.runs.run.Run; import net.neoforged.gradle.dsl.common.runs.type.RunType; import net.neoforged.gradle.util.StringCapitalizationUtils; @@ -61,7 +62,10 @@ public RunImpl(final Project project, final String name) { getWorkingDirectory().convention(project.getLayout().getProjectDirectory().dir("runs").dir(getName())); - getUseDevLogin().convention(false); + getUseDevLogin().convention( + project.getExtensions().getByType(Subsystems.class).getDevLogin().getConventionForRun() + .zip(getIsClient(), (devLogin, isClient) -> devLogin && isClient) + ); } @Override diff --git a/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/extensions/subsystems/DevLogin.groovy b/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/extensions/subsystems/DevLogin.groovy index 000dcb625..042fe5f1a 100644 --- a/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/extensions/subsystems/DevLogin.groovy +++ b/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/extensions/subsystems/DevLogin.groovy @@ -36,4 +36,12 @@ interface DevLogin extends ConfigurableDSLElement { @Optional @DSLProperty Property getConfigurationSuffix() + + /** + * @return The default usage flag state for runs. This is by default false (meaning the dev login configuration is not used by default), setting this to true will make all clients use dev login by default. + */ + @Input + @Optional + @DSLProperty + Property getConventionForRun() } \ No newline at end of file