albfan / mvnexec

bash script to find and execute java classes with main methods
18 stars 12 forks source link

need to add a new switch to skip running test #6

Open methor opened 5 years ago

methor commented 5 years ago

It seems the '-T' switch only ignore searching src/test for main classes, but I want to pass the -Dskiptest option to maven, in order to execute the selected main class only.

albfan commented 5 years ago

You just need something here:

https://github.com/albfan/mvnexec/blob/master/mvnexec#L119

mvn $QUIET install

will be replaced with:

mvn "$PARAMETERS" $QUIET install

That eventually will be:

mvn -DskipTests $QUIET install

I'm not sure about your needs so this can be a new parameter --config=-DskipTests or a new switch -t to skip test. See there're other ways to stop tests like -Dmaven.test.skip=true - which will avoid even compile test clases -.

@methor Are you able to provide a PR with those guidelines?

methor commented 5 years ago

@albfan I added two more switch, one of them corresponding to -DskipTests, the other -Dmaven.test.skip=true. When I test the script on my mac, since I haven't tested it yet,it has some trouble interpreting the 'getopt' and 'read -i' correctly on macos. Still working on it to make it more portable.

albfan commented 5 years ago

getopt is an external program, see http://abhipandey.com/2016/03/getopt-vs-getopts/

I think this would need some tweaks to be supported on mac (maybe rework on python), but please, keep that in a different issue.

In general, an option resembling another underneath program option is a bad idea, and hard to maintain. Let's see how it goes for test, but implement a --config option would be the most flexible solution

methor commented 5 years ago

Just pull request, applied your nice suggestions.

albfan commented 5 years ago

Merged. I just squash and change commit message.