Created
February 20, 2018 21:35
-
-
Save blaz-kranjc/0e891787f3a9b07b2506938234379098 to your computer and use it in GitHub Desktop.
A simple script that extracts javadoc from maven and opens it in firefox for easy documentation browsing.
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
#!/bin/bash | |
set -e | |
IFS=':' read -r -a fullArtifactId <<< "$1" | |
usage () { | |
echo "Usage: $0 <groupId>:<artifactId>:<version>" | |
} | |
if [ ${#fullArtifactId[@]} -ne 3 ] ; then | |
usage | |
echo "Please provide artifact in format <groupId>:<artifactId>:<version>" | |
exit 1 | |
fi | |
docsDir="$HOME/.mvnjavadoc" | |
thisDocDir="$docsDir/$1" | |
mkdir -p "$docsDir" "$thisDocDir" | |
thisDocJar="$thisDocDir/$1.jar" | |
if [ ! -f "$thisDocJar" ] ; then | |
mvn dependency:get -Dclassifier=javadoc \ | |
-DgroupId=${fullArtifactId[0]} \ | |
-DartifactId=${fullArtifactId[1]} \ | |
-Dversion=${fullArtifactId[2]} \ | |
-Ddest="$thisDocJar" | |
fi | |
thisDocHtmlDir="$thisDocDir/extracted" | |
mkdir -p "$thisDocHtmlDir" | |
if [ ! -f "$thisDocHtmlDir/index.html" ] ; then | |
unzip "$thisDocJar" -d "$thisDocHtmlDir" | |
fi | |
firefox "$thisDocHtmlDir/index.html" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment