[jbosstools-issues] [JBoss JIRA] (JBIDE-10196) Java build paths break when converting project to maven

Fred Bricon (Issue Comment Edited) (JIRA) jira-events at lists.jboss.org
Fri Nov 18 13:10:40 EST 2011


    [ https://issues.jboss.org/browse/JBIDE-10196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12644041#comment-12644041 ] 

Fred Bricon edited comment on JBIDE-10196 at 11/18/11 1:09 PM:
---------------------------------------------------------------

Full conversion of existing Eclipse projects into Maven ones is not supported in m2e (it barely creates a minimal pom.xml and enables the Maven nature and builder on the project). Existing classpath folders and classpath entries are not taken into account in the process. m2e only reads the pom.xml and infers a configuration based on the maven default conventions at this point. By default, the maven-compiler-plugin is configured to target Java 1.5, so m2e updates the project configuration to follow the pom.xml settings.

JBoss Tools introduces a somewhat better conversion mechanism to enhance the default m2e behavior :
* Right-Click on your project > Properties
* Go to the Project facets page
* Check JBoss Maven Integration, follow the "further configuration required" link
* fill in the maven project infos (choose packaging ejb)
* click ok and finish validate the changes

JBoss Tools will generate a pom.xml file having all the maven plugins configured according to the existing Eclipse project configuration. BUT, there is an important limitation : the classpath dependencies MUST be filled in manually in the pom. Previous existing Classpath Libraries (runtime, EAR ...) or classpath entries (local jars) should ALWAYS be superceded by the Maven Classpath Library. It's the one and only way to guarantee the project will build via command line. Updating the Maven project configuration will most likely remove them.


In your case, after the project is converted, you will have to add the Java EE  API (or the EJB API) dependency to your pom.xml, in order to compile your session bean.

However, if you're starting from scratch, the recommended way is to start creating a Maven project, using existing archetypes. That way the created project will follow the default maven conventions and won't requires heaps of xml configuration to follow the Eclipse conventions.

Full Eclipse -> Maven configuration will probably not happen in the near future, as it requires some changes in the m2e API.
                
      was (Author: fbricon):
    Full convertion of existing Eclipse projects into Maven ones is not supported in m2e (it barely creates a minimal pom.xml and enables the Maven nature and builder on the project). Existing classpath folders and classpath entries are not taken into account in the process. m2e only reads the pom.xml and infers a configuration based on the maven default conventions at this point. By default, the maven-compiler-plugin is configured to target Java 1.5, so m2e updates the project configuration to follow the pom.xml settings.

JBoss Tools introduces a somewhat better conversion mechanism to enhance the default m2e behavior :
* Right-Click on your project > Properties
* Go to the Project facets page
* Check JBoss Maven Integration, follow the "further configuration required" link
* fill in the maven project infos (choose packaging ejb)
* click ok and finish validate the changes

JBoss Tools will generate a pom.xml file having all the maven plugins configured according to the existing Eclipse project configuration. BUT, there is an important limitation : the classpath dependencies MUST be filled in manually in the pom. Previous existing Classpath Libraries (runtime, EAR ...) or classpath entries (local jars) should ALWAYS be superceded by the Maven Classpath Library. It's the one and only way to guarantee the project will build via command line. Updating the Maven project configuration will most likely remove them.


In your case, after the project is converted, you will have to add the Java EE  API (or the EJB API) dependency to your pom.xml, in order to compile your session bean.

However, if you're starting from scratch, the recommended way is to start creating a Maven project, using existing archetypes. That way the created project will follow the default maven conventions and won't requires heaps of xml configuration to follow the Eclipse conventions.

Full Eclipse -> Maven configuration will probably not happen in the near future, as it requires some changes in the m2e API.
                  
> Java build paths break when converting project to maven
> -------------------------------------------------------
>
>                 Key: JBIDE-10196
>                 URL: https://issues.jboss.org/browse/JBIDE-10196
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: maven, UpStream
>    Affects Versions: 3.3.0.M4
>         Environment: OSX Lion 10.7.2, JDK 1.6, Eclipse Java EE IDE for Web Developers, JBoss Tools updated today (18th Nov) from http://download.jboss.org/jbosstools/updates/development/indigo/
>            Reporter: Darrin Mison
>         Attachments: After_1.png, After_2.png, before_1.png, Before_2.png
>
>
> I created an EJB Project, added a session bean and converted it to a Maven project (via right-click, Configure->Convert to Maven Project).  Left default values in the Create POM dialog. 
> These two warnings and errors now manifest:
> ERROR:Java compiler level does not match the version of the installed Java project facet.
> WARNING:Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
> It appears to try to switch the Java build settings to use 1.5 although it was configured for 1.6.
> Before and after screenshots of settings changes attached.  
> Project builds again after changing the JRE in the Java Build Path/Libraries back to Java SE 6 (MacOS X Default) and the Compiler compliance level to 1.6

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbosstools-issues mailing list