Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] Maven Java project with custom packaging not imported properly

Thank You Igor

First I want to say, I'm looking for a way to configure everything
inside my Maven plugins (M2E lifecycle mappings files), so there will be no
need for end users to write mappings in Maven projects.

I would like to avoid writing custom M2E configurators if it will be
possible
to avoid problems with making them available for M2E (I don't know where
and how I would have to deploy them).

More details below...

On 2013-12-02 13:55, Igor Fedorenko wrote:
> Eclipse wiki [1] explains how to setup m2e development environment.
Thanks.
>
> By default java builder is only enabled for projects that use
> maven-compiler-plugin with compilerId=javac. If
> sbt-compiler-maven-plugin configuration parameters are compatible with
> maven-compiler-plugin, you should be able to use m2e standard java
> configurator [2]. You will have to write your own configurator if
> parameters are different.
My sbt-compiler-maven-plugin is similar to maven-compiler-plugin,
the main differences are:
1) it decides what to compile without need of additional help (from M2E
for example), SBT performs very sophisticated analysis, what sources
changed and what got invalidated because of those changes, it writes
analysis file and use it with next compilation
2) it compiles Java and Scala files

I examined sources of maven-compiler-plugin. Is it being called from M2E or
only it's configuration is being read and JDT is being called?
Maven-compiler-plugin does not use BuildContext, so I guess it's not
being called by M2E when building project.

Maven resources plugin on the other hand uses BuildContext (indirectly,
by using org.apache.maven.shared:maven-filtering dependency classes)

Tell me, does M2E call compiler and/or resources plugins mojos or not?

I tried sbt-compiler integration with simple jar projects (no custom
lifecycle,
Java and Scala sources).
First I configured sbt-compiler plugin to execute "compile" and
"testCompile"
mojos and added a code to emit messaged to BuildContext. It worked
quite well, but I wasn't sure whether Java files are not being compiled
twice:
by JDT and by sbt-compiled.
I removed sbt-compiler compilation goals from lifecycle mapping, installed
Scala IDE and added Scala nature to M2Eclipse projects. Everything
looked even better, so I think this is the right way (not to invoke my
compilation
mojos). Can you confirm?

Tell me if I'm wrong, but I think I cannot use
"org.eclipse.m2e.jdt.javaConfigurator"
because it's implementation class AbstractJavaProjectConfigurator checks
"maven-compiler-plugin" and "maven-resources-plugin" plugins with groupId
"org.apache.maven.plugins". These names are constants and I can only write
similar configurator for my packaging, not use this one.

>
> As explained in wiki [3], most maven plugins require use BuildContext in
> order participate in eclipse incremental and configuration builds. This
> is not enforced by m2e, but you are running risk of endless workspace
> builds and/or generated files go missing unless all filesystem changes
> go through BuildContext.
What exactly can be the reason of endless workspace builds?
>
> [1] http://wiki.eclipse.org/M2E_Development_Environment
> [2]
> http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/lifecycle-mapping-metadata.xml
> [3] https://wiki.eclipse.org/M2E_compatible_maven_plugins
>
> -- 
> Regards,
> Igor
>

One more funny thing. My test projects (jar packaging) for
sbt-compiler-maven-plugin
https://sbt-compiler-maven-plugin.googlecode.com/svn/tags/test-projects-1.0.0-beta2
work out of the box only because there is no way to remove
maven-compiler-plugin
from the Maven lifecycle.
There is:
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <skipMain>true</skipMain> <!-- skip compile -->
                    <skip>true</skip> <!-- skip testCompile -->
                </configuration>
            </plugin>
configuration in all of them to skip maven-compiler-plugin executions
entirely, but because
maven-compiler-plugin is still present in Maven jar lifecycle, all these
project are being imported
to M2E without problems (in contrast to test projects using "play2"
packaging, not containing
maven-compiler plugin in maven lifecycle at all).

Regards
Grzegorz Slowikowski

> On 12/2/2013, 2:38, Grzegorz Słowikowski wrote:
>> Hi
>>
>> I'm new to M2Eclipse integration, I'm adding it to my Maven plugins now.
>> Some of them define custom packagings and I have problem with one of
>> them.
>>
>> My plugin [1] defines custom packaging "play2" [2] producing Java "jar"
>> file.
>> M2Eclipse lifecycle mapping metadata definition file is here [3].
>>
>> When importing Maven project using "play2" packaging everything seems to
>> work: source generators
>> work, there is nothing in Eclipse workspace log, but after import there
>> is only ".project" file
>> with "maven2Builder" and "maven2Nature". No "javabuilder" and
>> "javanature" in ".project" file
>> and no ".classpath" file at all.
>>
>> Is there possibility to debug M2Eclipse import process?
>>
>> Current version 1.0.0-alpha6-SNAPSHOT deployed to Nexus Snapshot
>> repository so you can reproduce my problems.
>> Try importing of any of test projects [4], for example [5].
>>
>> I have similar Maven plugin with "play" (without "2" suffix) packaging
>> [6] and with that plugin everything works as expected
>> (you can check with any of test projects [7], for example [8]).
>>
>> [1] http://play2-maven-plugin.googlecode.com/svn/trunk/plugin
>> [2]
>> http://play2-maven-plugin.googlecode.com/svn/trunk/plugin/play2-maven-plugin/src/main/resources/META-INF/plexus/components.xml
>>
>> [3]
>> http://play2-maven-plugin.googlecode.com/svn/trunk/plugin/play2-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
>>
>> [4] http://play2-maven-plugin.googlecode.com/svn/trunk/test-projects/
>> [5]
>> http://play2-maven-plugin.googlecode.com/svn/trunk/test-projects/play21/java/helloworld/
>>
>>
>> [6]
>> http://maven-play-plugin.googlecode.com/svn/trunk/plugin/play-maven-plugin/
>>
>> [7] http://maven-play-plugin.googlecode.com/svn/trunk/test-projects/
>> [8]
>> http://maven-play-plugin.googlecode.com/svn/trunk/test-projects/findbugs/
>>
>>
>> Regards
>> Grzegorz Slowikowski
>>
>> _______________________________________________
>> m2e-dev mailing list
>> m2e-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/m2e-dev
>>
> _______________________________________________
> m2e-dev mailing list
> m2e-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/m2e-dev



Back to the top