Search code examples
gradlegrailsant

Running Gradle command from ant


The following is a snippet from my build.xml (which runs successfully)

<property name="gradlew" value="./gradlew"/>

<target name="test-functional" description="run functional tests">
    <antcall target="init"/>
    <antcall target="compile"/>
    <echo>Running functional tests...</echo>
    <exec executable="${gradlew}" failonerror="true">
        <arg value="iT"/>
        <!-- <arg value="iT --tests com.mygrailsapp.geb.** -Dgeb.env=firefox -Dgrails.server.port.http=8090"/> -->

    </exec>
</target>

But I only want to run my functional tests (under geb directory) with some additional options and so I comment in the second option in <exec> (which runs perfectly from the command line). But from ant, I get the following;

 [exec] * What went wrong:
 [exec] Task 'iT --tests com.mygrailsapp.geb.**' not found in root project 'mygrailsapp'.

Solution

  • Try this:

    <target name="test-functional" description="run functional tests">
        <antcall target="init"/>
        <antcall target="compile"/>
        <echo>Running functional tests...</echo>
        <exec executable="${gradlew}" failonerror="true">
            <arg value="iT"/>
            <arg value="--tests"/>
            <arg value="com.mygrailsapp.geb.**"/>
            <arg value="-Dgeb.env=firefox"/>
            <arg value="-Dgrails.server.port.http=8090"/>
        </exec>
    </target>