Skip to content

Instantly share code, notes, and snippets.

@scorpp
scorpp / gist:9207503
Last active August 29, 2015 13:56
Find all java files in current directory and move them in maven-correct directory with git
find . -type f -name '*.java' | \
while read f; do \
target=$(grep '^package ' $f | sed -e 's/package \+//' -e 's/;$//' -e 's/\./\//g'); \
newf="src/main/java/${target}/$(basename $f)"; \
mkdir -p $(dirname $newf); \
git mv $f $newf; \
chmod 644 $newf; \
done
@scorpp
scorpp / git merge a subdirectory
Last active December 19, 2015 09:39
GIT merge a subdirectory from another repo\branch
# http://stackoverflow.com/a/12048161/679052
$ git remote add Bar /path/to/bar
$ git merge -s ours --no-commit Bar/master
$ git read-tree --prefix=public/bar -u Bar/master:www/tools/
@scorpp
scorpp / put resources off java code
Last active December 16, 2015 00:09
Move all resource file from src/main/java to src/main/resources Needed sort files that way while migrating existing java projects to maven build system
find ./*/src/main/java/ -type f ! -name *.java | xargs -n 1 -P 1 -I{} bash -c "newdir=\$(echo \"\$(dirname {})\" | sed 's/src\/main\/java/src\/main\/resources/'); mkdir -p \$newdir; git mv {} \$newdir"