6

Now, I have already seen this question, however it doesn't appear anything is using my target folder.

What's going on, is when I compile it fails and shows me this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project FooProject: Error creating shaded jar: Failed to analyze class dependencies: C:\Users\paul_000\Documents\FooCore\target\classes (Access is denied) -> [Help 1]

I'm not quite sure exactly why this happens, as it doesn't happen on my normal computer.

EDIT: I forgot to mention, the jar I am shading does not exist on a repository. I just compile it locally (clean install). As well, here's what I use to shade:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <configuration>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <minimizeJar>true</minimizeJar>
            </configuration>
        </execution>
    </executions>
</plugin>
Community
  • 1
  • 1
PaulBGD
  • 2,018
  • 5
  • 22
  • 30
  • 1
    Maybe the target directory created with admin rights or is locked by another process. Using the -e switch to get the complete stacktrace will also help. – Tome Jun 02 '14 at 09:33
  • I'll check the full stacktrace, however it does not have admin rights (I am the only admin + I checked). I've restarted in safe mode to the same result, so I doubt it is a process. – PaulBGD Jun 02 '14 at 14:35

5 Answers5

9

You can face this error, if you're compiling from Eclipse with m2e plugin.

The workaround is to uncheck Resolve Workspace artifacts in the Maven Run Configuration.

enter image description here

Stephan
  • 41,764
  • 65
  • 238
  • 329
  • 2
    This solves previous problem but now I have problem that workspace artifact is not resolved... How can I have resolution turned on and get m2e plugin working? – svobol13 Nov 17 '15 at 11:19
  • @svobol13 The workspace artifact is not resolved because it can't be found in your local repository. Right click on that workspace artifact then click `Run As` an click on `Maven install`. Your project should compile fine now. – Stephan Feb 01 '16 at 23:23
  • Thanks Stephan, I wasted my whole day looking for why it was not creating war. – JavaDeveloper Feb 08 '16 at 14:46
  • Thanks this helped me with an error `... target/classes (Is a Directory)`. Is there any way to solve this in a different way than disabling 'Resolve Workspace artifacts'? – mxro Jun 21 '16 at 07:57
  • @mxro Can you post a new question with all the details of your particular case? Feel free to leave the link to the new question in a comment here. – Stephan Jun 21 '16 at 08:12
  • Here you go: [Question #37942689](http://stackoverflow.com/questions/37942689/maven-shade-plugin-reports-error-creating-shaded-jar-target-classes-is-a-d). Thanks! – mxro Jun 21 '16 at 11:04
1

I had a similar issue and as this is the first question that shows up on google, I add my solution as an answer here.
In my case, the problem was related to the dependencyReducedPomLocation I've set.
I wanted to move the dependency-reduced-pom to the target folder and so I've set the property to ${project.build.directory}.
However, this property does not expect a folder, but a file and the correct value for it would be ${project.build.directory}${file.separator}dependency-reduced-pom.xml.
After this change everything worked as expected.

Robert P
  • 9,398
  • 10
  • 58
  • 100
1

Upgrading maven-shade-plugin to 3.4.1 version resolved the issue.

San4musa
  • 277
  • 2
  • 12
0

I am using Eclipse Spring with the maven plugin. I was seeing a similar error in the logs:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project lds_ws_framework: Error creating shaded jar: C:\Users\fritchd\Documents\autoaction_archivetkitproject\target\classes (Access is denied) -> [Help 1]

I had recently updated my projects to use the maven-shade-plugin 2.3 from a different maven build process. I noticed I had a lot of artifacts from the previous process in the \target folder. So I tried just deleting all files under the \target directory for that project. When I reran the build, I didn't see the error.

dfritch
  • 329
  • 1
  • 3
  • 13
  • More than likely you had a program using a file in the directory, or you had a terminal inside that directory. – PaulBGD Jun 03 '15 at 01:39
0

Use the artifactSet option of maven-shade-plugin

For whatever reason this way Eclipse does not produce the "Access Denied" error

upperlimit
  • 35
  • 6