How can I display a more informative error message on ant errors?

When one of our developers mistakenly refers to the unrecognized target name ant, the result is an unfriendly error message, for example:

BUILD FAILED
Target "foo" does not exist in the project "bar". 

I would prefer it to run a goal instead, which displays a list of available goals. Is there a way to capture the ant error message and instead launch another target or some custom error message?

Thank.

+3
source share
3 answers

. , build.xml. , . ( ? ""?) , .

ant --projecthelp. ant -p.

, description , . build.xml description, ant --projecthelp description.

<description> build.xml, . :

<project name="Fubar" default="foo">

    <description>
        Project Fubar is a highly secret project that you shouldn't know
        anything about. If you have read this, you've violated national
        security guidelines and must be terminated with extreme finality.
        Hey, it hurts me more than  it hurts you.
    </description>

    <target name="foo"
        description="Runs target &quot;foo&quot;"/>

    <target name="fu"/>     <!-- Internal target No description -->

    <target name="bar"
        description="Runs target &quot;bar&quot;"/>
</project>

ant -p:

$ ant --projecthelp
Buildfile: build.xml

        Project Fubar is a highly secret project that you shouldn't know
        anything about. If you have read this, you've violated national
        security guidelines and must be terminated with extreme finality.
        Hey, it hurts me more than  it hurts you.

Main targets:

 bar  Runs target "bar"
 foo  Runs target "foo"
Default target: foo
$

: build.xml, target fu , .

+2
+1

ant -pdisplays a list of goals in your file build.xml. Is this good enough?

0
source

Source: https://habr.com/ru/post/1785987/


All Articles