-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform decompile step into a task that is customizable via specifi…
…c settings (#46) Example: ```gradle subsystems { decompiler { maxMemory = "2g" maxThreads = 4 logLevel = DecompilerLogLevel.TRACE jvmArgs = ["-verbose:gc'] } } ```
- Loading branch information
Showing
8 changed files
with
218 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
.../src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.neoforged.gradle.common.extensions.subsystems; | ||
|
||
import net.minecraftforge.gdi.ConfigurableDSLElement; | ||
import net.neoforged.gradle.dsl.common.extensions.subsystems.DecompilerLogLevel; | ||
import net.neoforged.gradle.dsl.common.extensions.subsystems.Subsystems; | ||
import org.gradle.api.GradleException; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.provider.ProviderFactory; | ||
|
||
import javax.inject.Inject; | ||
import java.util.Arrays; | ||
import java.util.Locale; | ||
|
||
public abstract class SubsystemsExtension implements ConfigurableDSLElement<Subsystems>, Subsystems { | ||
private static final String PROPERTY_PREFIX = "neogradle.subsystems."; | ||
private final Project project; | ||
|
||
@Inject | ||
public SubsystemsExtension(Project project) { | ||
this.project = project; | ||
|
||
ProviderFactory providers = project.getProviders(); | ||
getDecompiler().getMaxMemory().convention(providers.gradleProperty(PROPERTY_PREFIX + "decompiler.maxMemory")); | ||
getDecompiler().getMaxThreads().convention(providers.gradleProperty(PROPERTY_PREFIX + "decompiler.maxThreads").map(Integer::parseUnsignedInt)); | ||
getDecompiler().getLogLevel().convention(providers.gradleProperty(PROPERTY_PREFIX + "decompiler.logLevel").map(s -> { | ||
try { | ||
return DecompilerLogLevel.valueOf(s.toUpperCase(Locale.ROOT)); | ||
} catch (Exception e) { | ||
throw new GradleException("Unknown DecompilerLogLevel: " + s + ". Available options: " + Arrays.toString(DecompilerLogLevel.values())); | ||
} | ||
})); | ||
getDecompiler().getJvmArgs().convention(providers.gradleProperty(PROPERTY_PREFIX + "decompiler.jvmArgs").map(s -> Arrays.asList(s.split("\\s+")))); | ||
} | ||
|
||
@Override | ||
public Project getProject() { | ||
return project; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...n/src/main/groovy/net/neoforged/gradle/dsl/common/extensions/subsystems/Decompiler.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package net.neoforged.gradle.dsl.common.extensions.subsystems | ||
|
||
import groovy.transform.CompileStatic | ||
import net.minecraftforge.gdi.ConfigurableDSLElement | ||
import net.minecraftforge.gdi.annotations.DSLProperty | ||
import org.gradle.api.provider.ListProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Optional | ||
|
||
/** | ||
* Allows configuration of the decompiler used by NeoGradle. | ||
*/ | ||
@CompileStatic | ||
interface Decompiler extends ConfigurableDSLElement<Decompiler> { | ||
|
||
/** | ||
* Allows the maximum memory provided to the decompiler to be overridden. Must be specified | ||
* in the "123g" or "123m" form. | ||
*/ | ||
@Input | ||
@Optional | ||
@DSLProperty | ||
Property<String> getMaxMemory(); | ||
|
||
/** | ||
* Allows the maximum number of threads used by the decompiler to be constrained. By default, it will | ||
* use all available threads. | ||
*/ | ||
@Input | ||
@Optional | ||
@DSLProperty | ||
Property<Integer> getMaxThreads(); | ||
|
||
/** | ||
* The log-level to use for the decompiler. Supported values: trace, info, warn, error. | ||
* Defaults to {@link DecompilerLogLevel#INFO}. | ||
*/ | ||
@Input | ||
@Optional | ||
@DSLProperty | ||
Property<DecompilerLogLevel> getLogLevel(); | ||
|
||
/** | ||
* Allows additional JVM arguments to be added to the decompiler invocation. | ||
*/ | ||
@Input | ||
@Optional | ||
@DSLProperty | ||
ListProperty<String> getJvmArgs(); | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...in/groovy/net/neoforged/gradle/dsl/common/extensions/subsystems/DecompilerLogLevel.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.neoforged.gradle.dsl.common.extensions.subsystems | ||
|
||
enum DecompilerLogLevel { | ||
TRACE, | ||
INFO, | ||
WARN, | ||
ERROR | ||
} |
21 changes: 21 additions & 0 deletions
21
...n/src/main/groovy/net/neoforged/gradle/dsl/common/extensions/subsystems/Subsystems.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package net.neoforged.gradle.dsl.common.extensions.subsystems | ||
|
||
import groovy.transform.CompileStatic | ||
import net.minecraftforge.gdi.BaseDSLElement | ||
import net.minecraftforge.gdi.annotations.DSLProperty | ||
import org.gradle.api.tasks.Nested | ||
|
||
/** | ||
* Allows configuration of various NeoGradle subsystems. | ||
*/ | ||
@CompileStatic | ||
interface Subsystems extends BaseDSLElement<Subsystems> { | ||
|
||
/** | ||
* @return settings for the decompiler subsystem | ||
*/ | ||
@Nested | ||
@DSLProperty | ||
Decompiler getDecompiler(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters