Maven antrun plugin error


Errors of the same type look like this:

  • Element target is not allowed here
  • Cannot resolve symbol copy
  • Cannot resolve symbol fileset
  • Cannot resolve symbol copydir

Most likely this means that you have included the plugin in the pom.xml like this:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>copy-artifacts</id>
      <phase>package</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <target name="target_copy">
          ...
        </target>
      </configuration>
    </execution>
  </executions>
</plugin>

The reason for the error is that the plugin version is not specified. Let’s specify, for example, 1.8:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        ...
    </executions>
</plugin>

After that, you need to load changes from pom.xml to Maven and the error will disappear.