Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution fails for artifacts from workspace resolved projects #2

Open
lfryc opened this issue Jul 30, 2012 · 13 comments
Open

Execution fails for artifacts from workspace resolved projects #2

lfryc opened this issue Jul 30, 2012 · 13 comments

Comments

@lfryc
Copy link

lfryc commented Jul 30, 2012

Configuration:

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>test-unpack</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>org.richfaces.sandbox.ui.bootstrap</groupId>
                        <artifactId>bootstrap-ui</artifactId>
                        <version>4.3.0-SNAPSHOT</version>
                        <outputDirectory>${project.build.directory}/generated-resources/</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

Note that referenced artifactItem is resolved loaded into workspace.

Following error occurs:

Error unpacking file: /mnt/workspace/workspaces/richfaces/sandbox/bootstrap/ui/target/classes to: /mnt/workspace/workspaces/richfaces/sandbox/bootstrap/demo/target/generated-resources 
 org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory. (org.apache.maven.plugins:maven-dependency-plugin:2.4:unpack:test-unpack:generate-resources)

This is bug which maven-dependency-plugin suffers from:

@ianbrandt
Copy link
Owner

Just so I'm clear is org.richfaces.sandbox.ui.bootstrap:bootstrap-ui a module in the same build as the module containing the configuration snippet above?

If so then I'd agree that this is really a manifestation of MDEP-187/98. I've hit this bug before myself, and have voted for it in JIRA. If memory serves my only workaround was to reorganize my modules such that the needed resources were in the same project as I was trying to unpack into.

I'm not aware of anything I could do in the connector to work around this issue. I'm all ears if there are any suggestions? Otherwise I'm not sure what else I could do other than close this as "Can't Fix Here".

@lfryc
Copy link
Author

lfryc commented Jul 31, 2012

Yeah, let's close this - we can address it in scope of #1.

@ianbrandt
Copy link
Owner

Having slept on it the only option that has come to mind is to re-implement the Mojos in the connector itself. We'd then perform the unpack directly instead of invoking the Mojo itself, accounting of course for dependencies that resolve to directories as well as archives. Since the root bug can occur when invoking from the command line as well as from m2e, that wouldn't seem a very productive endeavor.

I've reached the current Maven Dependency Plugin maintainer on the Maven Dev mailing list. I'll see if I can't do anything to help expedite a fix in the plugin itself. It looks like there is a new release in the works. Hopefully we can act fast enough to get something for this included.

@lfryc
Copy link
Author

lfryc commented Aug 1, 2012

Awesome!

Thanks for bringing the issue under the light again. :-)

@ianbrandt ianbrandt changed the title Execution fails for goal unpack on workspace resolved project Execution fails for artifacts from workspace resolved projects Oct 14, 2014
@ianbrandt
Copy link
Owner

Migrating conversation from issue #1, @coderplus wrote:

m2e resolves the dependency/artifactItem to the outputDirectory of the workspace project if it's open in the workspace and the project which you are building has the resolve from workspace setting turned on.I managed to get around this for the copy and unpack goals by doing the unpack or copy from within the connector itself(without delegating to the plugin).

https://github.com/coderplus/m2e-maven-dependency-plugin/blob/master/core/src/com/coderplus/m2e/dependencycore/CoderPlusBuildParticipant.java

(most of it is copied from the maven-dependency-plugin source)

...and @karlvr wrote:

Registering my interest in this issue! It doesn't seem like you got anywhere with the original plugin author back in 2012? (reading that mail thread). I'm motivated to try to fix this; maybe we need to fork the dependency plugin itself and roll your m2e support into it. Do we have ideas on how to patch the dependency plugin?

@coderplus perhaps you have some thoughts? It looks like you've gone to some decent effort understanding the issue in your fork - but the idea of copying and pasting code feels not as great as forking the original plugin?

@aneesh-joseph
Copy link

I think that the issue is not with the plugin but M2E's Workspace resolution would mean that the dependencies or artifactItems which the maven-dependency-plugin tries to resolve will be resolved to the output directory of the corresponding workspace project(if workspace resolution is turned on and the dependency/artifactItem exists in workspace). I have amended the connector in such a way that the execution is not delegated to the plugin but is done within the connector itself. I have ignored the markers, but most of it does work though it is not tested well enough.Can you folks have a look at that?

@karlvr
Copy link

karlvr commented Oct 15, 2014

Thanks @coderplus. I guess this is a practical solution. I don't like the idea of copying a lot of functionality from the dependency plugin in order to achieve this, as I'm sure none of us do - perhaps it is the only way. Does it feel like it's impossible to get this support into the dependency plugin itself? I guess realistically the m2e support should be in there too - I know @ianbrandt has written about why there are advantages to the m2e support being separate, but it would obviously be tonnes easier if they were combined. Am I barking up the wrong tree?

@jakub-bochenski
Copy link

I'm confused, I thought this connector is supposed to solve the problem of unpacking workspace-resolved artifacts.
I think I'm still getting this problem with v0.4

Description Resource    Path    Location    Type
Artifact has not been packaged yet. When used on reactor artifact, unpack should be executed after packaging: see MDEP-98. (org.apache.maven.plugins:maven-dependency-plugin:2.10:unpack:unpack-placeholders:generate-test-resources)

org.apache.maven.plugin.MojoExecutionException: Artifact has not been packaged yet. When used on reactor artifact, unpack should be executed after packaging: see MDEP-98.
    at org.apache.maven.plugin.dependency.AbstractDependencyMojo.unpack(AbstractDependencyMojo.java:265)
    at org.apache.maven.plugin.dependency.fromConfiguration.UnpackMojo.unpackArtifact(UnpackMojo.java:127)
    at org.apache.maven.plugin.dependency.fromConfiguration.UnpackMojo.doExecute(UnpackMojo.java:106)
    at org.apache.maven.plugin.dependency.AbstractDependencyMojo.execute(AbstractDependencyMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
    at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
    at com.ianbrandt.tools.m2e.mdp.core.MdpBuildParticipant.executeMojo(MdpBuildParticipant.java:133)
    at com.ianbrandt.tools.m2e.mdp.core.MdpBuildParticipant.build(MdpBuildParticipant.java:67)
    at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
    pom.xml /common_pod line 5  Maven Build Problem

@jakub-bochenski
Copy link

PS. This appears when I do a clean build. After that, when I run Maven | Update project.. the marker disappears.

@srstsavage
Copy link

Confirmed, I still see the workspace-resolved artifact unpack issue mentioned above with version 0.0.4.201409291703. The error doesn't disappear after running Maven | Update project....

org.apache.maven.plugin.MojoExecutionException: Artifact has not been packaged yet. When used on reactor artifact, unpack should be executed after packaging: see MDEP-98.
    at org.apache.maven.plugin.dependency.AbstractDependencyMojo.unpack(AbstractDependencyMojo.java:229)
...

@srstsavage
Copy link

I've seen a lot of people having trouble with this issue, mostly in the maven-dependency-plugin JIRA and in StackOverflow questions. Seems like it's worth another push to try to get some resolution here. @ianbrandt, with the benefit of a few years of hindsight, any thoughts on where efforts should be targeted for a fix (here vs. maven-dependency-plugin vs m2e core?

@daveneeley
Copy link

MDEP-187 has a pull request attached to it. It was closed because tests were never added. apache/maven-plugins#31

@runeflobakk
Copy link

I just got hit by this issue again after starting fresh with a new Eclipse installation.
After installing @aneesh-joseph's connector (which I had installed on my old Eclipse, to resolve this exact problem I assume), the problem goes away by magic. It is available in the Marketplace for easy installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants