J Fabian Meier
J Fabian Meier

Reputation: 35795

Calling <if> from Maven-Antrun-Plugin

I use Maven-Antrun-Plugin 1.8 to execute an Ant target that contains an <if>.

I read that ant-contrib is necessary to run this, so I included the dependency to ant-contrib:ant-contrib:1.0b3. This causes ant:ant:1.5 to be loaded transitively, which breaks the build. If I put an exclusion on ant 1.5, the <if> is again undefined.

Summarized: I need a valid dependency listing for the maven-antrun-plugin that allows me to call <if>.

Upvotes: 0

Views: 1540

Answers (1)

calvin.lau
calvin.lau

Reputation: 76

Perhaps the following may help in your Maven pom:

<dependencies>
    <dependency>
        <groupId>ant-contrib</groupId>
        <artifactId>ant-contrib</artifactId>
        <version>1.0b3</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>ant</groupId>
                <artifactId>ant</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>ID_HERE</id>
                    <phase>PHASE_HERE</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target>
                            <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>
                            <if>
                                <!-- Some if condition here -->
                                <then>
                                    <!-- Ant tasks to execute if condition is true -->
                                </then>
                            </if>
                        </target>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>ant-contrib</groupId>
                    <artifactId>ant-contrib</artifactId>
                    <version>1.0b3</version>
                    <exclusions>
                        <exclusion>
                            <groupId>ant</groupId>
                            <artifactId>ant</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </plugin>
        </plugins>
    </build>

I understand that this may not be the most optimal/efficient solution to your issue, but this is exactly what I am currently using myself and it works with no issues.

Upvotes: 4

Related Questions