Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven3 antrun: failed to create task or type replaceregexp

I'm trying to write a simple task using Maven:

<plugin>
 <artifactId>maven-antrun-plugin</artifactId>
 <version>1.3</version>
 <executions>
  <execution>
    <phase>install</phase>
    <goals>
        <goal>run</goal>
    </goals>
    <configuration>
    <tasks>
     <replaceregexp file="dir=target/liquibase/*.sql" match="**DATABASECHANGELOGLOCK**" 
             replace="" byline="true" />
        </tasks>
    </configuration>
    </execution>
  </executions>
</plugin>

When I run this, I get

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project Tik
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.ReplaceRegExp was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME\lib
[ERROR] -the IDE Ant configuration dialogs
[ERROR]
[ERROR] Do not panic, this is a common problem.
[ERROR] The commonest cause is a missing JAR.
[ERROR]
[ERROR] This is not a bug; it is a configuration problem
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I have included the ant and ant-nodeps dependencies, but can't make it run, and googling around hasn't been any help.

Does anyone have a solution for this?

like image 588
Tom Avatar asked Dec 28 '22 18:12

Tom


1 Answers

I'm writing this in case anyone gets this problem

The problem was that maven doesn't care about ANT_HOME or anything. Dependencies must be declared inside the antrun plugin.

So I changed my pom.xml to look like this:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.3</version>
    <dependencies>
        <dependency>
            <groupId>ant</groupId>
            <artifactId>ant-nodeps</artifactId>
            <version>1.6.5</version>
        </dependency>
    </dependencies>
    <executions><execution>...</execution></executions>
</plugin>
like image 164
Tom Avatar answered Feb 20 '23 19:02

Tom