I occasionally receive this error when I build my project with
>mvn --version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 15:51:28+0200)
Maven home: ...\apache-maven-3.0.5
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: ...
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
and the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources
(default-resources) on project project-name: Cannot create resource output directory:
path\to\project\code\project-name\target\classes -> [Help 1]
Note: this happens sometimes, and it is not related to the code. It can happen in one of two consecutive builds - one after the other, against exactly the same source code.
Does anyone have any idea how to avoid it completely? It tends to interrupt quite a time-consuming build :-/
On Windows, there reasons for being unable to create a folder are:
Network shares are notoriously unreliable on Windows. Don't use them for any automated tasks. Always build projects with all files residing on a local hard disk.
If you use Maven and Eclipse to build at the same time, you should configure them to use different target folders. See https://stackoverflow.com/a/54366009/34088
Your POM should look like this:
<project>
...
<build>
<outputDirectory>${basedir}/${target.dir}/classes</outputDirectory>
<testOutputDirectory>${basedir}/${target.dir}/test-classes</testOutputDirectory>
</build>
<properties>
<target.dir>target</target.dir>
</properties>
<profiles>
<profile>
<id>eclipse-folders</id>
<properties>
<target.dir>target-eclipse</target.dir>
</properties>
</profile>
</profiles>
...
All that's left is to enable the profile eclipse-folders
in the IDE.
Disable the automatic build of your IDE (Eclipse or IntellJ IDEA or whatever). It will conflict with the Maven build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With