Skip to content

Instantly share code, notes, and snippets.

@blaz-kranjc
Created February 20, 2018 21:35
Show Gist options
  • Save blaz-kranjc/0e891787f3a9b07b2506938234379098 to your computer and use it in GitHub Desktop.
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.
#!/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