Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356167

Summary: otdt maven integration fails to build plain maven java project
Product: [Tools] Objectteams Reporter: Ivica Loncar <iloncar.ml>
Component: OTMvnAssignee: Project Teams <objectteams.otdt-inbox>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: stephan.herrmann
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Ivica Loncar CLA 2011-08-30 03:52:17 EDT
Build Identifier: 20110615-0604

I've followed instructions on your blog post, but when I installed maven integration for object teams (available at http://download.eclipse.org/objectteams/updates/contrib) plain java projects (just created from eclipse wizard) fail to build with errors:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile)
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (execution: default-testCompile, phase: test-compile)


If I add ot/j support to the project errors dissapear.

If I disable 

org.eclipse.objectteams.mvn.internal.LifeCycleMapping
and 
org.eclipse.objectteams.mvn.internal.Configurator 

plain maven projects work fine, as expected.

Other software:
- eclipse JEE Indigo release
- m2e latest release
- OTDT 2.0.0
- windows 7 - 64 bit


pom.xml that doesn't work:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

<!-- 	<parent> -->
<!-- 		<groupId>org.eclipse</groupId> -->
<!-- 		<artifactId>objectteams-parent-pom</artifactId> -->
<!-- 		<version>2.0.0</version> -->
<!-- 	</parent> -->


	<groupId>net.ilx.demo</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<repositories>
		<repository>
			<id>ObjectTeamsRepository</id>
			<name>Object Teams Repository</name>
			<url>http://download.eclipse.org/objectteams/maven/3/repository</url>
		</repository>
	</repositories>


	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
					<source>1.6</source>
					<target>1.6</target>
<!-- 					<compilerId>jdt</compilerId> -->
<!-- 					<flavor>otj</flavor> -->
				</configuration>
<!-- 				<dependencies> -->
<!-- 					<dependency> -->
<!-- 						<groupId>org.eclipse</groupId> -->
<!-- 						<artifactId>objectteams-otj-compiler</artifactId> -->
<!-- 						<version>2.0.0</version> -->
<!-- 						<scope>compile</scope> -->
<!-- 					</dependency> -->
<!-- 				</dependencies> -->
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>0.9.28</version>
		</dependency>
	</dependencies>

</project>


pom.xml that works:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

<!-- 	<parent> -->
<!-- 		<groupId>org.eclipse</groupId> -->
<!-- 		<artifactId>objectteams-parent-pom</artifactId> -->
<!-- 		<version>2.0.0</version> -->
<!-- 	</parent> -->


	<groupId>net.ilx.demo</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<repositories>
		<repository>
			<id>ObjectTeamsRepository</id>
			<name>Object Teams Repository</name>
			<url>http://download.eclipse.org/objectteams/maven/3/repository</url>
		</repository>
	</repositories>


	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
					<source>1.6</source>
					<target>1.6</target>
					<compilerId>jdt</compilerId>
					<flavor>otj</flavor>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>org.eclipse</groupId>
						<artifactId>objectteams-otj-compiler</artifactId>
						<version>2.0.0</version>
						<scope>compile</scope>
					</dependency>
				</dependencies>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>0.9.28</version>
		</dependency>
	</dependencies>

</project>


Reproducible: Always
Comment 1 Stephan Herrmann CLA 2011-08-31 18:33:08 EDT
Mh, that's interesting. 

The simplest workaround I can see right now is to add the following
to your plain-Java projects:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerId>jdt</compilerId>
                </configuration>
            </plugin>
        </plugins>
    </build>

This will tell the maven-compiler-plugin to use the JDT compiler for this
project. Now the existing lifecycle mapping will match the used compiler.
Without the flavor otj declaration the compiler will only accept plain Java.
But note, that within the OTDT this will still be the OT/J version of the
compiler.

During my first experiments I did not succeed to let the 
maven-compiler-plugin use different compilers (jdt & javac) within the
same workspace. Checking again today I find that a Java project can indeed
use javac even with ot.mvn installed by specifying:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerId>javac</compilerId>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.apache.maven.plugins
                                        </groupId>
                                        <artifactId>
                                            maven-compiler-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.3.2,)
                                        </versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                            <goal>testCompile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <configurator>
                                          <id>org.eclipse.m2e.jdt.javaConfigurator</id>
                                        </configurator>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

This is still only a workaround. I'll leave this bug open for
investigating ways to support plain Java without additional tweaks but
still provide the option to manage OT/J projects, too.

Please also let me know if these workarounds don't work for you.
Comment 2 Stephan Herrmann CLA 2011-08-31 19:42:51 EDT
I found a better way to support the jdt compiler without breaking
support for javac.

Please update org.eclipse.objectteams.mvn to 1.0.0.201109010126.
With this update the plain Java project should work again with or
without mentioning the maven-compiler-plugin.

Feel free to re-open if the issue is not solved for you.

(not setting a target milestone as this plugin is still early access).
Comment 3 Ivica Loncar CLA 2011-09-02 07:35:27 EDT
Yep. It seems to work.
Comment 4 Stephan Herrmann CLA 2011-09-03 08:31:14 EDT
(In reply to comment #3)
> Yep. It seems to work.

Thanks for confirming.