Skip to content

Commit

Permalink
Add property binding and docs for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Nov 29, 2023
1 parent a60fff5 commit 004b16c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ NeoGradle

Minecraft mod development framework used by NeoForge and FML for the Gradle build system.

For a quick start, see how the [NeoForge Mod Development Kit](https://github.com/neoforged/MDK) uses NeoGradle, or see our official [Documentation](https://docs.neoforged.net/neogradle/docs/).
For a quick start, see how the [NeoForge Mod Development Kit](https://github.com/neoforged/MDK) uses NeoGradle, or see
our official [Documentation](https://docs.neoforged.net/neogradle/docs/).

To see the latest available version of NeoGradle, visit
the [NeoForged Maven](https://maven.neoforged.net/#/releases/net/neoforged/gradle/userdev).

## Override Decompiler Settings

The settings used by the decompiler when preparing Minecraft dependencies can be overridden
using [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties).
This can be useful to trade slower build-times for being able to run NeoGradle on lower-end machines.

| Property | Description |
|----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| `neogradle.subsystems.decompiler.maxMemory` | How much heap memory is given to the decompiler. Can be specified either in gigabyte (`4g`) or megabyte (`4096m`). |
| `neogradle.subsystems.decompiler.maxThreads` | By default the decompiler uses all available CPU cores. This setting can be used to limit it to a given number of threads. |
| `neogradle.subsystems.decompiler.logLevel` | Can be used to override the [decompiler loglevel](https://vineflower.org/usage/#cmdoption-log). |
| `neogradle.subsystems.decompiler.jvmArgs` | Pass arbitrary JVM arguments to the decompiler. I.e. `-XX:+HeapDumpOnOutOfMemoryError` |

To see the latest available version of NeoGradle, visit the [NeoForged Maven](https://maven.neoforged.net/#/releases/net/neoforged/gradle/userdev).
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
import net.minecraftforge.gdi.ConfigurableDSLElement;
import net.neoforged.gradle.dsl.common.extensions.subsystems.Subsystems;
import org.gradle.api.Project;
import org.gradle.api.provider.ProviderFactory;

import javax.inject.Inject;
import java.util.Arrays;

public abstract class SubsystemsExtension implements ConfigurableDSLElement<Subsystems>, Subsystems {
private final Project project;

@Inject
public SubsystemsExtension(Project project) {
this.project = project;

ProviderFactory providers = project.getProviders();
getDecompiler().getMaxMemory().convention(providers.gradleProperty("neogradle.subsystems.decompiler.maxMemory"));
getDecompiler().getMaxThreads().convention(providers.gradleProperty("neogradle.subsystems.decompiler.maxThreads").map(Integer::parseUnsignedInt));
getDecompiler().getLogLevel().convention(providers.gradleProperty("neogradle.subsystems.decompiler.logLevel"));
getDecompiler().getJvmArgs().convention(providers.gradleProperty("neogradle.subsystems.decompiler.jvmArgs").map(s -> Arrays.asList(s.split("\\s+"))));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ private static TaskProvider<? extends Runtime> createDecompile(NeoFormRuntimeSpe
int maxThreads = settings.getMaxThreads().getOrElse(0);
String logLevel = settings.getLogLevel().getOrElse("INFO");

jvmArgs.addAll(settings.getJvmArgs().get());
if (settings.getJvmArgs().isPresent()) {
jvmArgs.addAll(settings.getJvmArgs().get());
}
jvmArgs.add("-Xmx" + maxMemory);
if (maxThreads > 0) {
decompilerArgs.add(0, "-thr=" + maxThreads);
Expand Down

0 comments on commit 004b16c

Please sign in to comment.