I occasionally receive this error when I build my project with
>mvn --version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602
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.
For me the reason for this was only being in said folder with my git bash while building. Ensure that you don't happen to have the said folder open in any other program.
Disable the automatic build of your IDE (Eclipse or IntellJ IDEA or whatever). It will conflict with the Maven build.
My issue was resolved when I gave mvn clean
command from windows coammandprompt
I experience this issue every time I run the command while I have the output folder or the parent folder opened in Windows Explorer.
If I move one level above the parent, the build ends successfully.
I had the exact same issue when trying to run the First Cup tutorial.
I fixed it by simply closing NetBeans and running it as administrator (via right click).