You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.
As @dsyer mentioned in #4mvnw doesn't play well with sub-modules.
I'm currently using this little helper script, a copy of which I drop into every sub-module. It traverses up the directories to find the root project (a directory that contains pom.xml, mvnw, and .mvn/wrapper). It then runs the top level mvnw, passing the sub-module it was executed from and --also-make (to build dependencies as well).
As workarounds go this has been working well for me for the last 10 months or so, but it would be neat if mvnw supported this out of the box.
In it's simplest form "support" could mean mvnw ships this script and provides a way to drop a copy into a sub-module on request (having the script in each module is quite nice in that you can always say ./mvnw ... rather than having to supply the right number of ../....
Alternatively some of this logic could be integrated into mvnw directly so that when run from a sub-directory the relevant maven arguments are injected automatically. The per-module mvnw script could then potentially be replaced with a symlink.
#!/bin/bash
# child-mvnw: Finds the top-level project and invokes a reactor build there
path=""; cd "$(dirname "$0")"
while true; do
if [ "$PWD" = "/" ]; then echo "Unable to find project root" >&2; exit 1; fi
path="$(basename "$PWD")/$path"; cd ..
[ -f pom.xml -a -f mvnw -a -d .mvn/wrapper ] && break
done
exec ./mvnw --projects "${path%/}" --also-make "$@"
If there's interest in this I'd be happy to provide a pull request (for non-Windows platforms at least, don't have a Windows machine on hand to test with), but I wanted to see if anybody else cares about this feature and/or other ideas to approach it.
The text was updated successfully, but these errors were encountered:
What I do is create a bash alias/function that does the same thing. You can't really integrate this into mvnw because it won't be on the PATH. The whole point of the wrapper is that it is self-contained. Here's my alias in case anyone else wants to use it:
function mvn {
dir=`pwd`
while [ -e $dir/pom.xml ] && ! [ -e $dir/mvnw ] && ! [ -z $dir ]; do dir=${dir%/*}; done
if [ -e $dir/mvnw ]; then
echo "Running wrapper at $dir"
$dir/mvnw $@
return $?
fi
echo No wrapper found, running native Maven
`which mvn` $@
}
I put that in my .bashrc (and a similar one for gradle).
Thanks, that's a neat way of switching between mvnw and stand-alone mvn.
The feature of my script that I was wondering if mvnw could support directly is running mvn with --projects pointed to the current sub-module (i.e. it actually runs a reactor build on the top-level project, but limited to the current module and it's dependencies).
I suppose I would have the same problem with standalone mvn rather than mvnw, so maybe it's not a feature that mvnw should provide directly.
As @dsyer mentioned in #4
mvnw
doesn't play well with sub-modules.I'm currently using this little helper script, a copy of which I drop into every sub-module. It traverses up the directories to find the root project (a directory that contains
pom.xml
,mvnw
, and.mvn/wrapper
). It then runs the top levelmvnw
, passing the sub-module it was executed from and--also-make
(to build dependencies as well).As workarounds go this has been working well for me for the last 10 months or so, but it would be neat if
mvnw
supported this out of the box.In it's simplest form "support" could mean
mvnw
ships this script and provides a way to drop a copy into a sub-module on request (having the script in each module is quite nice in that you can always say./mvnw ...
rather than having to supply the right number of../...
.Alternatively some of this logic could be integrated into
mvnw
directly so that when run from a sub-directory the relevant maven arguments are injected automatically. The per-modulemvnw
script could then potentially be replaced with a symlink.If there's interest in this I'd be happy to provide a pull request (for non-Windows platforms at least, don't have a Windows machine on hand to test with), but I wanted to see if anybody else cares about this feature and/or other ideas to approach it.
The text was updated successfully, but these errors were encountered: