Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] [m2e-users] Detaching project from build reactor before executing a mojo

Thank you folks :-) I managed to copy or unpack the artifacts without delegating the execution to the maven-dependency-plugin (shamelessly copied most of the code from the actual maven plugin).


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


On Thu, Oct 2, 2014 at 9:43 PM, Igor Fedorenko <igor@xxxxxxxxxxxxxx> wrote:
This is plain java, you can run any code you want. Personally, I would
just implement the logic you need, but if you really need/want
to execute a mojo you can see how we do that in m2e-tycho configurator
[1]. There, instead of running 'bundle' goal, the code executes
'manifest' goal. You can use the same technique to run any plugin goal,
as long as you can construct meaningful configuration.

[1] https://github.com/tesla/m2eclipse-tycho/blob/master/org.sonatype.tycho.m2e/src/org/sonatype/tycho/m2e/felix/internal/MavenBundlePluginConfigurator.java#L190

--
Regards,
Igor

On 2014-10-02, 11:37, CoderPlus Team wrote:
Thanks for the very quick response. I now understand that
the DefaultArtifactResolver resolves the dependency to the output
directory of the dependency and hence the plugin is not able to copy the
file and if that part of the plugin is rewritten appropriately, it could
work as expected.

While creating a configurator for the maven-dependency-plugin  is it
possible to delegate the execution to an alternate maven mojo(some class
which extends org.apache.maven.plugin.AbstractMojo) which is part of the
connector plugin.

Thanks,
Aneesh

On Wed, Oct 1, 2014 at 5:49 PM, Igor Fedorenko <igor@xxxxxxxxxxxxxx
<mailto:igor@xxxxxxxxxxxxxx>> wrote:

    There is no reactor during m2e workspace build, each project is built
    independently.

    Normally, projects resolve dependencies from workspace before checking
    local/remote repositories. Workspace dependency resolution can be
    disabled, but this most likely isn't what you want.

    It is possible change dependency plugin to copy with unpacked
    dependencies, as I suggested in MDEP-187. It is also possible to
    reimplement relevant dependency-plugin functionality in your connector.
    This is probably the easiest short-term solution. Or you can implement
    new maven plugin that does what you need and works with unpacked
    dependencies.

    Other notes and observations

    If configurator simply delegates to the mojo, it is almost always better
    to enable m2e integration in the maven plugin itself, as explained in
    [1]. This way your users will not need to install any additional eclipse
    plugins, everything will "just work".

    You need to decide what happens during eclipse workspace incremental
    build. Your configurator (or the plugin) will be called each time
    anything project resource is changed, so you need to make absolutely
    sure your configurator does not change filesystem on each execution.

    Also, please use m2e-dev to ask any follow-up questions you might (and
    this kind of questions in general).

    [1] https://wiki.eclipse.org/M2E___compatible_maven_plugins

    <https://wiki.eclipse.org/M2E_compatible_maven_plugins>

    --
    Regards,
    Igor


    On 2014-10-01, 8:02, CoderPlus Team wrote:

        Hi all,
        I'm trying to create a connector for the maven-dependency-plugin
        (copy,
        unpack goals etc). If the dependency which has to be copied or
        unpacked
        is already open in the workspace, while executing the mojo via a
        configurator, then the plugin throws the below error

        /Artifact has not been packaged yet. When used on reactor
        artifact, copy
        should be executed after packaging: see MDEP-187 is thrown/


        This doesn't go away if the dependent project is configured to
        package
        the dependency during an m2e build.


        So,basically I'm trying to detach the dependent project from the
        reactor
        before invoking the plugin via m2eclipse and add it back after the
        execution.

        Is this possible? Is it possible to programatically find out
        what all
        artifactitems are part of the build reactor and remove the ones
        you want
        to exclude?


        _________________________________________________
        m2e-users mailing list
        m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
        To change your delivery options, retrieve your password, or
        unsubscribe from this list, visit
        https://dev.eclipse.org/__mailman/listinfo/m2e-users
        <https://dev.eclipse.org/mailman/listinfo/m2e-users>

    _________________________________________________
    m2e-users mailing list
    m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
    To change your delivery options, retrieve your password, or
    unsubscribe from this list, visit
    https://dev.eclipse.org/__mailman/listinfo/m2e-users
    <https://dev.eclipse.org/mailman/listinfo/m2e-users>




_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/m2e-dev

_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/m2e-dev


Back to the top