Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-resources-plugin:2.5 - Cannot create resource output directory

Tags:

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 :-/

like image 715
Mateva Avatar asked Jul 22 '14 12:07

Mateva


2 Answers

On Windows, there reasons for being unable to create a folder are:

  1. Some other process is deleting this folder at the same time
  2. You don't have permissions to access this folder
  3. The folder is on a network share

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.

like image 179
Aaron Digulla Avatar answered Sep 21 '22 14:09

Aaron Digulla


Disable the automatic build of your IDE (Eclipse or IntellJ IDEA or whatever). It will conflict with the Maven build.

like image 24
Jens Baitinger Avatar answered Sep 20 '22 14:09

Jens Baitinger