Created
February 9, 2010 00:01
-
-
Save mrdon/298752 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
# This script creates a parent pom for all listed modules, allowing you to open them up in IDEA | |
# in one go and have IDEA automatically link up dependencies | |
if [ "$1" == "--help" -o $# -lt 2 ]; then | |
echo "Usage: wksp.sh WORKSPACE_NAME MODULE_NAME..." | |
echo "" | |
echo "This command is meant to be ran from the root directory for all projects" | |
exit 1 | |
fi | |
base=`pwd` | |
# Use the _name-workspace pattern to ensure the module is the first one in IDEA | |
wsName="_$1-workspace" | |
# Get rid of the workspace name so it isn't mistaken for a module later on | |
shift | |
wsDir="$base/.maven-workspace/$wsName" | |
if [ ! -d $wsDir ]; | |
then | |
mkdir -p $wsDir | |
fi | |
wsPom="$wsDir/pom.xml" | |
echo "<project" > $wsPom | |
echo " xmlns=\"http://maven.apache.org/POM/4.0.0\"" >> $wsPom | |
echo " xlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " >> $wsPom | |
echo " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">" >> $wsPom | |
echo " " >> $wsPom | |
echo " <modelVersion>4.0.0</modelVersion>" >> $wsPom | |
echo " " >> $wsPom | |
echo " <groupId>maven-workspace</groupId>" >> $wsPom | |
echo " <artifactId>$wsName</artifactId>" >> $wsPom | |
echo " <version>1</version>" >> $wsPom | |
echo " <packaging>pom</packaging>" >> $wsPom | |
echo " " >> $wsPom | |
echo " <modules>" >> $wsPom | |
while [ "$1" ] | |
do | |
rawModuleName="$1" | |
# Strip any trailing / | |
moduleName=`echo $rawModuleName | sed -e 's/\(.*\)\//\1/'` | |
echo " <module>../../$moduleName</module>" >> $wsPom | |
shift | |
done | |
echo " </modules>" >> $wsPom | |
echo "</project>" >> $wsPom | |
echo "Workspace created at $wsPom" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment