Home > Java > Over typing -Dskip.junit=true

Over typing -Dskip.junit=true

by paul on March 13, 2009

I generally prefer Maven2, but I’m currently on a project using a custom ant build script – and I’m over having to type -Dskip.junit=true when I just want to generate a quick jar without running the tests.

To easily switch off tests, I modified ant.bat so that it looks for a command line parameter ’st’ and if found, it will substitute it with -Dskip.junit=true.

In Ant 1.7.0, you just need to change line 68 in block ‘:setupArgs’ from

set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1

to

if “”%1″”==”"st”" (set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% -Dskip.junit=true) else (set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1)

So, the whole block reads (from line 65):

:setupArgs
if “”%1″”==”"”" goto doneStart
if “”%1″”==”"-noclasspath”" goto clearclasspath
if “”%1″”==”"st”" (set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% -Dskip.junit=true) else (set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1)
shift
goto setupArgs

Now, I can just type

ant all st

Leave a Comment

Previous post:

Next post: