Maven3 antrun:无法创建任务或键入replaceregexp

Tom*_*Tom 4 ant replace maven-3

我试图用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>
Run Code Online (Sandbox Code Playgroud)

当我跑这个时,我明白了

[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
Run Code Online (Sandbox Code Playgroud)

我已经包含了antant-nodeps依赖项,但无法使其运行,并且谷歌搜索没有任何帮助.

有人有解决方案吗?

提前致谢.

Tom*_*Tom 8

我正在写这个,万一有人得到这个问题

问题是maven并不关心ANT_HOME或任何事情.必须在antrun插件中声明依赖项.

所以我改变了我pom.xml的样子:

<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>
Run Code Online (Sandbox Code Playgroud)