Skip to content

Commit

Permalink
Redirect to a run property.
Browse files Browse the repository at this point in the history
Update documentation.
Error out when the user adds dev login to a none client run.
  • Loading branch information
marchermans committed May 29, 2024
1 parent bc375fc commit 37cf12f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,20 @@ neogradle.subsystems.devLogin.addRepositories=<true/false>
By default, the repositories are added, but if you want to disable this, you can set the property to false.
By doing so you are responsible for adding a maven repository that provides the dev login CLI artifact.

### Per run configuration
If you want to configure the dev login tool per run, you can do so by setting the following properties in your run configuration:
```groovy
runs {
someRun {
shouldUseDevLogin false
}
}
```
This will disable the dev login tool for this run. By default, the dev login tool is enabled for all client runs.

> [!WARNING]
> If you enable the dev login tool for a none client run, you will get an error message.
## Centralized Cache
NeoGradle has a centralized cache that can be used to store the decompiled Minecraft sources, the recompiled Minecraft sources, and other task outputs of complex tasks.
The cache is enabled by default, and can be disabled by setting the following property in your gradle.properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private void applyAfterEvaluate(final Project project) {
final Tools tools = project.getExtensions().getByType(Subsystems.class).getTools();
if (devLogin.getEnabled().get()) {
//Dev login is only supported on the client side
if (runImpl.getIsClient().get()) {
if (runImpl.getIsClient().get() && runImpl.getShouldUseDevLogin().get()) {
final String mainClass = runImpl.getMainClass().get();

//We add the dev login tool to the runtime only configuration, of the first source set, this should suffice
Expand All @@ -398,6 +398,8 @@ private void applyAfterEvaluate(final Project project) {

//Set the main class to the dev login tool
run.getMainClass().set("net.covers1624.devlogin.DevLogin");
} else if (!runImpl.getIsClient().get() && runImpl.getShouldUseDevLogin().get()) {
throw new GradleException("Dev login is only supported on runs which are marked as clients! The run: " + runImpl.getName() + " is not a client run.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public RunImpl(final Project project, final String name) {
getConfigureFromDependencies().convention(getConfigureAutomatically());

getWorkingDirectory().convention(project.getLayout().getProjectDirectory().dir("runs").dir(getName()));

getShouldUseDevLogin().convention(getIsClient());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.neoforged.gradle.dsl.common.runs.run

import groovy.cli.Option
import groovy.transform.CompileStatic
import net.minecraftforge.gdi.BaseDSLElement
import net.minecraftforge.gdi.NamedDSLElement
Expand Down Expand Up @@ -156,6 +157,16 @@ interface Run extends BaseDSLElement<Run>, NamedDSLElement {
@Optional
abstract Property<Boolean> getIsGameTest();

/**
* Indicates if this run should use the dev login.
*
* @return {@code true} if this run uses dev login; otherwise, {@code false}.
*/
@Input
@DSLProperty
@Optional
abstract Property<Boolean> getShouldUseDevLogin();

/**
* Defines the source sets that are used as a mod.
* <p>
Expand Down

0 comments on commit 37cf12f

Please sign in to comment.