Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366118 - [xtend-maven-plugin] Lifecycle mapping required for M2E
Summary: [xtend-maven-plugin] Lifecycle mapping required for M2E
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-08 16:48 EST by Karsten Thoms CLA
Modified: 2017-10-31 10:57 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Thoms CLA 2011-12-08 16:48:11 EST
When using the M2E plugin the POM is marked with an error:

Plugin execution not covered by lifecycle configuration: org.eclipse.xtend2:xtend-maven-plugin:2.2.0:compile (execution: default, phase: generate-sources)

See this for details:
http://wiki.eclipse.org/M2E_plugin_execution_not_covered

Some additional work on the plugin is required to avoid additional configuration in the POM, see:
http://wiki.eclipse.org/M2E_Extension_Development


To resolve the error marker in the POM this can be added as workaround:
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings 
          only. It has no influence on the Maven build itself. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>
                      org.eclipse.xtend2
                    </groupId>
                    <artifactId>
                      xtend-maven-plugin
                    </artifactId>
                    <versionRange>
                      [2.2.0,)
                    </versionRange>
                    <goals>
                      <goal>compile</goal>
                      <goal>testCompile</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
Comment 1 Karsten Thoms CLA 2011-12-08 16:52:03 EST
To reproduce:
- install M2E plugin from Indigo update site
- use project from here: https://github.com/kthoms/xtext-experimental/tree/bug366118
Comment 2 Sven Efftinge CLA 2011-12-09 00:44:23 EST
There is a plugin and feature for this, have a look at the update site. Please reopen if this doesn't work for you.
Comment 3 Dietrich Schulten CLA 2012-01-09 02:48:03 EST
This seems to refer to the feature Xtend M2E Extensions
org.eclipse.xtext.xtend2.m2e.feature.group in the http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/ updatesite
Comment 4 Dietrich Schulten CLA 2012-01-09 05:18:14 EST
The extension should not just ignore the xtend plugin. If I understand correctly, it should provide a build participant that refreshes the workspace after generation and a project configurator that adds the generated source as eclipse classpath. 

I have just recently implemented this for the fornax oaw maven plugin.

If you are not already working on this, I could provide a patch for the xtend-maven-plugin in git.

Is the fornax oaw maven plugin in git, or do I have to send an SVN patch for it, and to whom should I send it?

Best regards,
Dietrich
Comment 5 Sven Efftinge CLA 2012-01-09 06:06:58 EST
It's a no-op implementation, since the IDE (i.e. Xtend builder) takes care of everything.
Comment 6 Dietrich Schulten CLA 2012-01-09 11:59:43 EST
(In reply to comment #5)
> It's a no-op implementation, since the IDE (i.e. Xtend builder) takes care of
> everything.

Does it also add the folder containing the generated sources? There is always the possibility to use build-helper, but the maven project can configure itself correctly without that, if the project configurator is added. Another point might be adding the XText nature for a maven project with xtext dependency. Does such an m2e extension make sense from your point of view? If so, I'll take a look.

Best regards,
Dietrich
Comment 7 Sven Efftinge CLA 2012-01-10 02:31:18 EST
It does everything that should be done, because it should work nicely for non-Maven users too.
Comment 8 Hendy Irawan CLA 2012-01-10 02:58:30 EST
+1 for this
Comment 9 Karsten Thoms CLA 2012-01-10 03:36:55 EST
 
> Is the fornax oaw maven plugin in git, or do I have to send an SVN patch for
> it, and to whom should I send it?
The Fornax plugin is hosted in the Fornax project at SourceForge. https://fornax.svn.sourceforge.net/svnroot/fornax/trunk/toolsupport/maven2/fornax-toolsupport-oaw-m2-plugin/trunk/

I am in charge of this plugin, and am planning a 3.4.0 release. This lifecycle mapping could be a valuable addition. You can send patches to me.
Comment 10 Andreas Sewe CLA 2013-07-07 13:25:11 EDT
Can we please re-open this bug? IMHO, the "Xtend M2E Extensions" should at least, upon an "Maven/Update Project", add an "org.eclipse.xtext.ui.shared.xtextNature" to the respective project whenever m2e discovers the xtend-maven-plugin being used in the build.

Moreover, they should also configure the (per-project) Xtend Compiler output directory such that it matches the value of outputDirectory as found in the POM's plugin configuration (this will be difficult, though, until Bug 409759 is fixed).

Currently, using "Import/Maven/Existing Maven projects" just doesn't work if I the xtend-maven-plugin in my build -- unless I check in the Eclipse-specific .project and .setting files in addition to the generic pom.xml.
Comment 11 Sven Efftinge CLA 2013-08-06 04:06:42 EDT
(In reply to comment #10)
> Can we please re-open this bug? 

Sure :-)

> IMHO, the "Xtend M2E Extensions" should at
> least, upon an "Maven/Update Project", add an
> "org.eclipse.xtext.ui.shared.xtextNature" to the respective project whenever
> m2e discovers the xtend-maven-plugin being used in the build.

Maven doesn't need the nature and the IDE will add it as soon as it needs it.

> 
> Moreover, they should also configure the (per-project) Xtend Compiler output
> directory such that it matches the value of outputDirectory as found in the
> POM's plugin configuration (this will be difficult, though, until Bug 409759
> is fixed).

Yes, that sounds reasonable.
Note that you can already refer to the xtend project settings form within the maven plugin. So basically the otherway around.

> 
> Currently, using "Import/Maven/Existing Maven projects" just doesn't work if
> I the xtend-maven-plugin in my build -- unless I check in the
> Eclipse-specific .project and .setting files in addition to the generic
> pom.xml.

Why doesn't it work? What's the problem?
Comment 12 Andreas Sewe CLA 2013-08-06 08:52:37 EDT
>> IMHO, the "Xtend M2E Extensions" should at
>> least, upon an "Maven/Update Project", add an
>> "org.eclipse.xtext.ui.shared.xtextNature" to the respective project whenever
>> m2e discovers the xtend-maven-plugin being used in the build.
> 
> Maven doesn't need the nature and the IDE will add it as soon as it needs it.

Assume I want to check in only Maven's pom.xml, but no IDE-specific configuration (.project, .classpath, .settings, etc.). Then an "Import / As existing Maven project" should, thanks to m2e, generate all necessary Eclipse-specific files, without me having redundant information in the SCM.

Unfortunately, that doesn't *quite* work for Xtend, since "as soon as it needs it" is as soon as I open the first Xtend file in my freshly imported project. If I don't open it, the Xtend compiler never runs (as the fresh import lacks the Xtend nature), and the Java compiler spits out errors whenever there's a reference from a "Java class" to an "Xtend class" (as it hasn't been compiled yet).

That's the reason why we at Eclipse Code Recommenders check in the .project files of projects that use Xtend [1]; the Xtend compiler should be aware of .xtend classes from the get go. But those projects are the only projects where we have to check in .project and friends. Other projects [2] work fine with a pom.xml alone; there, m2e takes care of deriving an appropriate .project from the pom.xml.
 
>> Moreover, they should also configure the (per-project) Xtend Compiler output
>> directory such that it matches the value of outputDirectory as found in the
>> POM's plugin configuration (this will be difficult, though, until Bug 409759
>> is fixed).
> 
> Yes, that sounds reasonable.
> Note that you can already refer to the xtend project settings form within
> the maven plugin. So basically the otherway around.

I don't get this. Do you mean the xtend-maven-plugin reads a .settings/org.eclipse.xtend.core.Xtend.prefs?

FWIW, here's our configuration of said plugin [3] at Eclipse Code Recommenders.
 
>> Currently, using "Import/Maven/Existing Maven projects" just doesn't work if
>> I the xtend-maven-plugin in my build -- unless I check in the
>> Eclipse-specific .project and .setting files in addition to the generic
>> pom.xml.
> 
> Why doesn't it work? What's the problem?

As describe above: no Xtend nature -> (Java) compiler errors.

Hope that explains things.

[1] <https://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/tree/tests/org.eclipse.recommenders.rcp.tests/.project?id=181b9d949966c1221520c09259a6579cdb2e7a37>

[2] <https://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/tree/tests/org.eclipse.recommenders.jayes.tests?id=181b9d949966c1221520c09259a6579cdb2e7a37>

[3] <https://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/tree/pom.xml?id=181b9d949966c1221520c09259a6579cdb2e7a37#n384>
Comment 13 Sven Efftinge CLA 2013-08-06 09:11:10 EDT
I see. Thanks for the explanation.

(In reply to comment #12)
> > Note that you can already refer to the xtend project settings form within
> > the maven plugin. So basically the otherway around.
> 
> I don't get this. Do you mean the xtend-maven-plugin reads a
> .settings/org.eclipse.xtend.core.Xtend.prefs?

yes, you can point to it from within the maven pom.
Comment 14 Andreas Sewe CLA 2013-08-06 10:01:36 EDT
(In reply to comment #13)
>(In reply to comment #12)
>>> Note that you can already refer to the xtend project settings form within
>>> the maven plugin. So basically the otherway around.
>> 
>> I don't get this. Do you mean the xtend-maven-plugin reads a
>> .settings/org.eclipse.xtend.core.Xtend.prefs?
> 
> yes, you can point to it from within the maven pom.

Do you mean "point" in the sense of "there is a Maven <configuration> element for it" (I couldn't find one) or in the sense of "the xtend-maven-plugin autodetects an existing .settings/org.eclipse.xtend.core.Xtend.prefs and simply (silently?) uses that"?
Comment 15 Sven Efftinge CLA 2013-08-06 10:38:27 EDT

(In reply to comment #14)
> (In reply to comment #13)
> >(In reply to comment #12)
> >>> Note that you can already refer to the xtend project settings form within
> >>> the maven plugin. So basically the otherway around.
> >> 
> >> I don't get this. Do you mean the xtend-maven-plugin reads a
> >> .settings/org.eclipse.xtend.core.Xtend.prefs?
> > 
> > yes, you can point to it from within the maven pom.
> 
> Do you mean "point" in the sense of "there is a Maven <configuration>
> element for it" (I couldn't find one) or in the sense of "the
> xtend-maven-plugin autodetects an existing
> .settings/org.eclipse.xtend.core.Xtend.prefs and simply (silently?) uses
> that"?

It is in org.eclipse.xtend.maven.AbstractXtendCompilerMojo

	/**
	 * Location of the Xtend settings file.
	 * 
	 * @parameter default-value="${basedir}/.settings/org.eclipse.xtend.core.Xtend.prefs"
	 * @readonly
	 */
	private String propertiesFileLocation;

It can be set explicitly but is automatically used in case the outputDirectory hasn't been set explicitly.
Comment 16 Stefan Oehme CLA 2014-04-10 02:25:53 EDT
This was fixed in 2.5.0
Comment 17 Eclipse Webmaster CLA 2017-10-31 10:46:08 EDT
Requested via bug 522520.

-M.
Comment 18 Eclipse Webmaster CLA 2017-10-31 10:57:22 EDT
Requested via bug 522520.

-M.