Maven:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources
Solution 1:
With:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
Was getting the following exception:
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Mark invalid
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:306)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 25 more
Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Mark invalid
at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:129)
at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:264)
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:300)
... 27 more
Caused by: java.io.IOException: Mark invalid
at java.io.BufferedReader.reset(BufferedReader.java:505)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:416)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:205)
at java.io.Reader.read(Reader.java:140)
at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:181)
at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:168)
at org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1856)
at org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1804)
at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:114)
... 29 more
Then it is gone after adding maven-filtering 1.3:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
Solution 2:
remove this work for me:
<filtering>true</filtering>
I guess it is caused by this filtering bug
Solution 3:
I had this issue too because I was filtering /src/main/resources and forgot I had added a keystore (*.jks) binary to this directory.
Add a "resource" block with exclusions for binary files and your problem may be resolved.
<build>
<finalName>somename</finalName>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
</testResource>
</testResources>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>*.jks</exclude>
<exclude>*.png</exclude>
</excludes>
</resource>
</resources>
...
Solution 4:
What worked for me is to add include tag in order to specify exactly what I want to filter.
It seems the resource plugin has problems going through the whole src/main/resource folder, probably due to some specific files inside.
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>application.yml</include>
</includes>
</resource>
</resources>
Solution 5:
In my case the targetPath
was not having any value it was blank in the resources --> resource
for the file directory
with files that had issue.
I had to update it to global
as seen in the Code Sample 2
and re-run build to fix the issue.
Code Sample 1 (with issue)
<build>
<resources>
<resource>
<directory>src/main/locale</directory>
<filtering>true</filtering>
<targetPath></targetPath>
<includes>
<include>*.xml</include>
<include>*.config</include>
<include>*.properties</include>
</includes>
</resource>
</resources>
Code Sample 2 (fix applied)
<build>
<resources>
<resource>
<directory>src/main/locale</directory>
<filtering>true</filtering>
<targetPath>global</targetPath>
<includes>
<include>*.xml</include>
<include>*.config</include>
<include>*.properties</include>
</includes>
</resource>
</resources>