Resolve workspace artifacts option in Eclipse generates error when one of the resolving projects is opened

2.3k views Asked by At

I have a maven project A, with 4 submodules. I have another maven project B, without any submodules. One of the 4 submodules of A, references project B.

When I do clean install on project A, I receive an error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project dca-web: Failed to copy file for artifact [be.vlaanderen.dwse:dwse-doc-tools:jar:3.2.2:compile]: /Users/Fabrizio/ontwikkeling/projecten/doc-tools/target/classes (Is a directory)

When enabling debug information: it is clear what is the issue:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project dca-web: Failed to copy file for artifact [be.vlaanderen.dwse:dwse-doc-tools:jar:3.2.2:compile]: /Users/Fabrizio/ontwikkeling/projecten/doc-tools/target/classes (Is a directory) -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project dca-web: Failed to copy file for artifact [be.vlaanderen.dwse:dwse-doc-tools:jar:3.2.2:compile] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216) at org.apache.maven.cli.MavenCli.main(MavenCli.java:160) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to copy file for artifact [be.vlaanderen.dwse:dwse-doc-tools:jar:3.2.2:compile] at org.apache.maven.plugin.war.packaging.ArtifactsPackagingTask.performPackaging(ArtifactsPackagingTask.java:131) at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.handleArtifacts(WarProjectPackagingTask.java:190) at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.performPackaging(WarProjectPackagingTask.java:109) at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:472) at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:404) at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:215) at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:177) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 19 more

Caused by: java.io.FileNotFoundException: /Users/Fabrizio/ontwikkeling/projecten/doc-tools/target/classes (Is a directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(FileInputStream.java:138) at org.codehaus.plexus.util.io.FileInputStreamFacade.getInputStream(FileInputStreamFacade.java:36) at org.codehaus.plexus.util.FileUtils.copyStreamToFile(FileUtils.java:1141) at org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1048) at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:293) at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask$1.registered(AbstractWarPackagingTask.java:150) at org.apache.maven.plugin.war.util.WebappStructure.registerFile(WebappStructure.java:211) at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:145) at org.apache.maven.plugin.war.packaging.ArtifactsPackagingTask.performPackaging(ArtifactsPackagingTask.java:106)

But the folder target/classes is a directory! So there is a bug somewhere in one of the maven plugins I guess...

When I close project B, there is no problem. So opening the referenced project creates an issue...

I need to have project B open, because I use project A as a web application in Tomcat. When I have project B open and i change a file and save it, Eclipse does an incremental publish, and therefore Tomcat doesn't need to redeploy or restart! This saves me for each file change like 30 seconds! So it is very important to keep this project open...

1

There are 1 answers

2
onderbewustzijn On BEST ANSWER

I found the solution. Apparently eclipse luna (or any eclipse luna based ide) is using an embedded version of maven, which in turn uses the maven-war-plugin version 2.2. After adding in my pom the version 2.6, it solved the issue!

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
        </plugin>
    </plugins>
</build>