#!/bin/bash# Source: https://bitbucket.org/jhult/workspace/snippets/7eg4r4# This script attempts to follow this style guide: https://google.github.io/styleguide/shellguide.html#s7-naming-conventionsreadonlyJAR="$1"readonlyDIR_TMP="/tmp"readonlyDIR_SRC="$DIR_TMP/src_$JAR"readonlyDIR_NO_COMMENTS="$DIR_TMP/src_no_comm_$JAR"readonlyFILE_CFR="$DIR_TMP/cfr.jar"readonlyFILE_JCP="$DIR_TMP/jcp.jar"readonlyVERSION_CFR=0.152
readonlyVERSION_JCP=7.1.2
readonlyURL_CFR="https://github.com/leibnitz27/cfr/releases/download/$VERSION_CFR/cfr-$VERSION_CFR.jar"readonlyURL_JCP="https://github.com/raydac/java-comment-preprocessor/releases/download/$VERSION_JCP/jcp-$VERSION_JCP.jar"download(){echo"Downloading: $2 ..." curl -fsSL "$1" -o "$2"}check_param(){if["$#"==""];thenecho"You must enter a JAR file as the first and only parameter."exit1fi}exists_or_download(){# If JAR file does not exist, download itif ! test -f "$1";then# Default to CFRlocalURL="$URL_CFR"if["$1"=="$FILE_JCP"];thenURL="$URL_JCP"fi download "$URL""$1"fi}main(){ check_param "$@"echo"This script will decompile $JAR and remove any comments." exists_or_download "$FILE_CFR" exists_or_download "$FILE_JCP" java -jar "$FILE_CFR" --outputdir "$DIR_SRC""$JAR" java -jar "$FILE_JCP" --i:"$DIR_SRC" --o:"$DIR_NO_COMMENTS" -ef:none --r
rm -rf "$DIR_SRC"echo"JAR decompiled here: $DIR_NO_COMMENTS"}main "$@"
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.