├── settings.gradle ├── .gitignore ├── MCModDecompiler.bat ├── MCModDecompiler.sh ├── libs └── jd-core-java-1.2.jar ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ └── java │ └── com │ └── choonster │ └── mcmoddecompiler │ ├── commandline │ ├── PathConverter.java │ ├── DirectoryPathValidator.java │ └── Arguments.java │ ├── Main.java │ ├── MCPData.java │ └── ModDecompiler.java ├── .gitattributes ├── LICENSE.txt ├── README.md ├── gradlew.bat └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'MinecraftModDecompiler' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | build/ 3 | 4 | *.ipr 5 | *.iml 6 | *.iws -------------------------------------------------------------------------------- /MCModDecompiler.bat: -------------------------------------------------------------------------------- 1 | REM @echo off 2 | java -jar build/libs/MinecraftModDecompiler-1.0-withdeps.jar %* -------------------------------------------------------------------------------- /MCModDecompiler.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | java -jar build/libs/MinecraftModDecompiler-1.0-withdeps.jar "$@" -------------------------------------------------------------------------------- /libs/jd-core-java-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Choonster-Minecraft-Mods/MinecraftModDecompiler/HEAD/libs/jd-core-java-1.2.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Choonster-Minecraft-Mods/MinecraftModDecompiler/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 19 14:17:29 EST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip 7 | -------------------------------------------------------------------------------- /src/main/java/com/choonster/mcmoddecompiler/commandline/PathConverter.java: -------------------------------------------------------------------------------- 1 | package com.choonster.mcmoddecompiler.commandline; 2 | 3 | import com.beust.jcommander.IStringConverter; 4 | 5 | import java.nio.file.Path; 6 | import java.nio.file.Paths; 7 | 8 | public class PathConverter implements IStringConverter { 9 | 10 | @Override 11 | public Path convert(String value) { 12 | return Paths.get(value); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /src/main/java/com/choonster/mcmoddecompiler/commandline/DirectoryPathValidator.java: -------------------------------------------------------------------------------- 1 | package com.choonster.mcmoddecompiler.commandline; 2 | 3 | import com.beust.jcommander.IParameterValidator; 4 | import com.beust.jcommander.ParameterException; 5 | 6 | import java.nio.file.Files; 7 | import java.nio.file.Path; 8 | import java.nio.file.Paths; 9 | 10 | public class DirectoryPathValidator implements IParameterValidator { 11 | 12 | @Override 13 | public void validate(String name, String value) throws ParameterException { 14 | Path path = Paths.get(value); 15 | if (!Files.isDirectory(path)) { 16 | throw new ParameterException("Parameter " + name + " (" + String.valueOf(value) + ") must be a directory"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/choonster/mcmoddecompiler/commandline/Arguments.java: -------------------------------------------------------------------------------- 1 | package com.choonster.mcmoddecompiler.commandline; 2 | 3 | import com.beust.jcommander.Parameter; 4 | 5 | import java.nio.file.Path; 6 | 7 | public class Arguments { 8 | 9 | @Parameter(names = "-modDirectory", description = "The directory containing the mods to decompile", required = true, converter = PathConverter.class, validateWith = DirectoryPathValidator.class) 10 | public Path modDirectory; 11 | 12 | @Parameter(names = "-outputDirectory", description = "The directory to output the decompiled classes to", required = true, converter = PathConverter.class, validateWith = DirectoryPathValidator.class) 13 | public Path outputDirectory; 14 | 15 | @Parameter(names = "-mappingsDirectory", description = "The directory containing the MCP mapping files (fields.csv and methods.csv)", required = true, converter = PathConverter.class, validateWith = DirectoryPathValidator.class) 16 | public Path mappingsDirectory; 17 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Choonster 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/main/java/com/choonster/mcmoddecompiler/Main.java: -------------------------------------------------------------------------------- 1 | package com.choonster.mcmoddecompiler; 2 | 3 | import com.beust.jcommander.JCommander; 4 | import com.beust.jcommander.ParameterException; 5 | import com.choonster.mcmoddecompiler.commandline.Arguments; 6 | 7 | import java.io.IOException; 8 | import java.nio.file.Path; 9 | import java.util.List; 10 | 11 | public class Main { 12 | 13 | public static void main(String[] args) { 14 | Arguments arguments = new Arguments(); 15 | 16 | JCommander jCommander = new JCommander(); 17 | jCommander.setProgramName("java -jar MinecraftModDecompiler.jar"); 18 | jCommander.addObject(arguments); 19 | 20 | try { 21 | jCommander.parse(args); 22 | } catch (ParameterException e) { 23 | System.out.printf("Error: %s\n\n", e.getMessage()); 24 | jCommander.usage(); 25 | exit(); 26 | } 27 | 28 | 29 | ModDecompiler decompiler = null; 30 | try { 31 | decompiler = new ModDecompiler(arguments.modDirectory, arguments.outputDirectory, arguments.mappingsDirectory); 32 | } catch (IOException e) { 33 | System.err.println("Exception initialising MCP data"); 34 | e.printStackTrace(); 35 | exit(); 36 | } 37 | 38 | List errors = decompiler.decompile(); 39 | if (errors.size() > 0) { 40 | System.err.println("Errored mods:"); 41 | System.err.println(errors.toString()); 42 | exit(); 43 | } 44 | } 45 | 46 | private static void exit() { 47 | System.exit(-1); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/choonster/mcmoddecompiler/MCPData.java: -------------------------------------------------------------------------------- 1 | package com.choonster.mcmoddecompiler; 2 | 3 | import com.opencsv.CSVReader; 4 | import org.apache.commons.lang3.ArrayUtils; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | import java.io.IOException; 8 | import java.nio.file.Files; 9 | import java.nio.file.Path; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class MCPData { 14 | 15 | private final MappingData data; 16 | 17 | public MCPData(Path mcpMappingsDirectory) throws IOException { 18 | MappingData methods = readCSV(mcpMappingsDirectory.resolve("methods.csv")); 19 | MappingData fields = readCSV(mcpMappingsDirectory.resolve("fields.csv")); 20 | 21 | data = MappingData.join(methods, fields); 22 | } 23 | 24 | public String deobfuscate(String sourceCode) { 25 | return StringUtils.replaceEach(sourceCode, data.srgNames, data.deobfNames); 26 | } 27 | 28 | private MappingData readCSV(Path path) throws IOException { 29 | List srgNames = new ArrayList<>(), deobfNames = new ArrayList<>(); 30 | CSVReader parser = new CSVReader(Files.newBufferedReader(path)); 31 | 32 | for (String[] line : parser) { 33 | srgNames.add(line[0]); 34 | deobfNames.add(line[1]); 35 | } 36 | 37 | return new MappingData(srgNames.toArray(ArrayUtils.EMPTY_STRING_ARRAY), deobfNames.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); 38 | } 39 | 40 | private static class MappingData { 41 | public final String[] srgNames; 42 | public final String[] deobfNames; 43 | 44 | public MappingData(String[] srgNames, String[] deobfNames) { 45 | this.srgNames = srgNames; 46 | this.deobfNames = deobfNames; 47 | } 48 | 49 | public static MappingData join(MappingData data1, MappingData data2) { 50 | String[] srgNames = ArrayUtils.addAll(data1.srgNames, data2.srgNames); 51 | String[] deobfName = ArrayUtils.addAll(data1.deobfNames, data2.deobfNames); 52 | 53 | return new MappingData(srgNames, deobfName); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discontinued 2 | This project has been discontinued. I recommend using [BON2](https://github.com/tterrag1098/BON2) to deobfuscate mods and a regular Java decompiler to decompile them. 3 | 4 | # Minecraft Mod Decompiler 5 | Decompiles and deobfuscates all Minecraft Forge mods in a specified directory and outputs the source files to another directory. 6 | 7 | Please respect the individual mod licenses when using this tool. 8 | 9 | ## Supported Platforms 10 | This tool uses [JD-Core-java](https://github.com/nviennot/jd-core-java) for decompilation. 11 | 12 | JD itself supports: 13 | - Linux 32/64-bit 14 | - Windows 32/64-bit 15 | - Mac OSX 32/64-bit on x86 hardware 16 | 17 | ## Build 18 | Clone the repository and run `gradlew build`. This will generate two JAR files in the `build/libs` directory: 19 | - `MinecraftModDecompiler-.jar`, which contains only this tool 20 | - `MinecraftModDecompiler--withdeps.jar`, which contains this tool and all of its dependencies 21 | 22 | The `idea` and `eclipse` Gradle plugins are included in the build script, so you can run `gradlew idea` or `gradlew eclipse` to generate an IDE project. 23 | 24 | ## Usage 25 | ```shell 26 | java -jar MinecraftModDecompiler.jar [options] 27 | Options: 28 | * -mappingsDirectory 29 | The directory containing the MCP mapping files (fields.csv and methods.csv) 30 | * -modDirectory 31 | The directory containing the mods to decompile 32 | * -outputDirectory 33 | The directory to output the decompiled classes to 34 | ``` 35 | 36 | For convenience, the included `MCModDecompiler` batch/shell scripts can be run with the same arguments after building in a cloned repository. 37 | 38 | The MCP mapping files can be found in the [MCP releases](http://www.modcoderpack.com/website/releases) under the `conf` directory. If you've set up a ForgeGrqadle workspace, you can also find the mapping files in your Gradle cache (`~/.gradle/caches/minecraft/net/minecraftforge/forge//unpacked/conf` for Minecraft 1.7.2 and later). 39 | 40 | ## License 41 | MinecraftModDecompiler is released under the MIT license. See `LICENSE.txt` for details. 42 | 43 | JD-IntelliJ (included with JD-Core-java) is free for non-commercial use. This means that JD-IntelliJ shall not be included or embedded into commercial software products. Nevertheless, this tool may be freely used for personal needs in a commercial or non-commercial environments. 44 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/main/java/com/choonster/mcmoddecompiler/ModDecompiler.java: -------------------------------------------------------------------------------- 1 | package com.choonster.mcmoddecompiler; 2 | 3 | import jd.core.Decompiler; 4 | import jd.core.DecompilerException; 5 | 6 | import java.io.IOException; 7 | import java.nio.file.DirectoryStream; 8 | import java.nio.file.Files; 9 | import java.nio.file.Path; 10 | import java.util.ArrayList; 11 | import java.util.Iterator; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | public class ModDecompiler { 16 | private Path modDirectory; 17 | private Path outputDirectory; 18 | private Decompiler decompiler; 19 | private MCPData mcpData; 20 | 21 | public ModDecompiler(Path modDirectory, Path outputDirectory, Path mappingsDirectory) throws IOException { 22 | this.modDirectory = modDirectory; 23 | this.outputDirectory = outputDirectory; 24 | 25 | this.decompiler = new Decompiler(); 26 | this.mcpData = new MCPData(mappingsDirectory); 27 | } 28 | 29 | public List decompile() { 30 | List errors = new ArrayList<>(); 31 | 32 | System.out.printf("Starting decompilation of mods in %s to %s\n", modDirectory.toString(), outputDirectory.toString()); 33 | decompileDirectory(modDirectory, errors); 34 | System.out.printf("Decompilation complete."); 35 | 36 | return errors; 37 | } 38 | 39 | private void decompileDirectory(Path directory, List errors) { 40 | System.out.printf("\n\nEntering directory %s...\n", modDirectory.relativize(directory).toString()); 41 | 42 | try (DirectoryStream stream = Files.newDirectoryStream(directory)) { 43 | for (Path entry : stream) { 44 | if (Files.isDirectory(entry)) { 45 | decompileDirectory(entry, errors); 46 | } else if (hasExtension(entry, ".jar") || hasExtension(entry, ".zip")) { 47 | try { 48 | decompileJAR(entry); 49 | } catch (Exception e) { 50 | errors.add(entry); 51 | System.err.printf("Exception decompiling %s:\n", entry.getFileName().toString()); 52 | e.printStackTrace(); 53 | } 54 | } 55 | } 56 | } catch (IOException e) { 57 | System.err.println("Exception iterating directory:"); 58 | e.printStackTrace(); 59 | } 60 | } 61 | 62 | private boolean hasExtension(Path path, String extension) { 63 | return path.toString().endsWith(extension); 64 | } 65 | 66 | private void decompileJAR(Path jar) throws IOException, DecompilerException { 67 | String jarName = jar.getFileName().toString(); 68 | 69 | System.out.printf("\n\nDecompiling %s...\n", jarName); 70 | Map pathToSrc = decompiler.decompile(jar.toString()); 71 | 72 | System.out.println("Deobfuscating..."); 73 | for (Iterator> iterator = pathToSrc.entrySet().iterator(); iterator.hasNext(); ) { 74 | Map.Entry entry = iterator.next(); 75 | String path = entry.getKey(); 76 | if (path.endsWith(".java")) { 77 | pathToSrc.put(path, mcpData.deobfuscate(entry.getValue())); // Deobfuscate each Java file 78 | } else { 79 | iterator.remove(); // Remove non-Java files 80 | } 81 | } 82 | 83 | decompiler.decompileToDir(outputDirectory.toString(), pathToSrc); 84 | System.out.println("Complete"); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | --------------------------------------------------------------------------------