Skip to content

Commit 93120cf

Browse files
committed
Relocate shaded dependencies
1 parent 121edfc commit 93120cf

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

build.gradle

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
31
plugins {
42
id 'java-library'
53
id 'idea'
@@ -65,7 +63,7 @@ tasks.named('jar', Jar) {
6563
from configurations.named('include').map { it.findAll { it.name.endsWith('jar') }.collect { zipTree(it) } }
6664
}
6765

68-
tasks.named('shadowJar', ShadowJar) {
66+
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
6967
manifest {
7068
attributes([
7169
'Main-Class' : 'net.minecraftforge.accesstransformer.TransformerProcessor',
@@ -75,6 +73,16 @@ tasks.named('shadowJar', ShadowJar) {
7573

7674
archiveClassifier = 'fatjar'
7775
exclude '**/Log4j2Plugins.dat'
76+
77+
enableAutoRelocation = true
78+
relocationPrefix = 'net.minecraftforge.accesstransformer.shadow'
79+
// Rewrite JOpt's message files, so that help text is displayed nicely.
80+
transform(com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer) {
81+
paths = [ 'Messages.properties$' ]
82+
keyTransformer = { key -> 'net.minecraftforge.accesstransformer.shadow.' + key }
83+
}
84+
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer)
85+
transform(com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer)
7886
}
7987

8088
changelog {

src/main/java/net/minecraftforge/accesstransformer/TransformerProcessor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ public static void main(String... args) {
3434
final ArgumentAcceptingOptionSpec<Path> atFiles = optionParser.acceptsAll(list("atfile", "atFile"), "Access Transformer File").withRequiredArg().withValuesConvertedBy(new PathConverter(PathProperties.FILE_EXISTING)).required();
3535
final ArgumentAcceptingOptionSpec<Path> outputJar = optionParser.accepts("outJar", "Output JAR file").withRequiredArg().withValuesConvertedBy(new PathConverter());
3636
final ArgumentAcceptingOptionSpec<String> logFilePath = optionParser.accepts("logFile", "Log file for logging").withRequiredArg();
37+
final OptionSpec<Void> help = optionParser.accepts("help").forHelp();
3738

3839
final OptionSet optionSet;
3940
Path inputJarPath;
4041
Path outputJarPath;
4142
List<Path> atFilePaths;
4243
try {
4344
optionSet = optionParser.parse(args);
45+
if (optionSet.has(help)) {
46+
optionParser.printHelpOn(System.out);
47+
return;
48+
}
49+
4450
final String logFile = logFilePath.value(optionSet);
4551
if (logFile != null) {
4652
// configure a custom logfile with debug level logging
@@ -69,6 +75,10 @@ public static void main(String... args) {
6975
atFilePaths = atFiles.values(optionSet).stream().map(Path::toAbsolutePath).collect(Collectors.toList());
7076
} catch (Exception e) {
7177
LOGGER.error(AXFORM_MARKER,"Option Parsing Error", e);
78+
try {
79+
optionParser.printHelpOn(System.out);
80+
} catch (IOException e1) {
81+
}
7282
return;
7383
}
7484
LOGGER.info(AXFORM_MARKER, "Access Transformer processor running version {}", TransformerProcessor.class.getPackage().getImplementationVersion());

0 commit comments

Comments
 (0)