Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
608 views
in Technique[技术] by (71.8m points)

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

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: 
 pathoprojectcodeproject-nameargetclasses -> [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 :-/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...