Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359340 - [patch] Provide a way to allow customization of the maven model when converting to a Maven project
Summary: [patch] Provide a way to allow customization of the maven model when converti...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Igor Fedorenko CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 346843 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-09-29 02:20 EDT by Fred Bricon CLA
Modified: 2021-04-19 13:24 EDT (History)
4 users (show)

See Also:


Attachments
Proposed patch to implement the feature (36.44 KB, patch)
2012-01-04 08:48 EST, Fred Bricon CLA
igor: iplog+
Details | Diff
Test cases for project conversion (33.76 KB, patch)
2012-01-04 08:49 EST, Fred Bricon CLA
no flags Details | Diff
Test cases for project conversion including eclipse settings (52.26 KB, patch)
2012-01-28 19:18 EST, Fred Bricon CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fred Bricon CLA 2011-09-29 02:20:18 EDT
Build Identifier: 

When converting an existing Eclipse project to a Maven project, we loose most/all of the existing Eclipse configuration, as the Maven model is created from a minimal Wizard and serialized directly as a pom.xml

the configure() method of projects configurators is meant to configure projects in Eclipse according to their existing pom.xml. We need to be able to do the same thing, but the other way around.

Use case : I'm converting an existing Dynamic Web application to a Maven project. I expect :
- The java project configurator to add/configure existing source directories and the maven-compiler-plugin to the Maven project model, according to the existing Java configuration.
- The WTP project configurator to add/configure the warSourceDirectory of maven-war-plugin 



Reproducible: Always
Comment 1 Fred Bricon CLA 2011-12-31 04:51:03 EST
After thinking and discussing about that with Igor, here are a few more ideas  :

Eclipse plugins would  contribute to a new extension point and implement a new interface, let's call it IProjectConversionParticipant, having 2 methods :
- boolean accept(IProject project)
- void convert(IProject project, Model mavenModel)

On the Configure > Convert to Maven project action/command, after the user has chosen the GAV coordinates and package for the project in the wizard, instead of serializing the maven model directly, all conversion participants are retrieved (ordered with a priority would be a good idea) and called in that fashion :

for (IProjectConversionParticipant converter : getProjectConversionParticipants() {
  if (converter.accept(project) {
    converter.convert(project, model);
  }
} 

That way :
* m2e-jdt (highest priority) adds the maven-compiler-plugin to the model if the javaNature is present on the project, setting the source/target values based on the existing eclipse settings
* m2e-wtp adds the maven-war-plugin, maven-ear-plugin, maven-ejb-plugin and so on, based on existing installed project facets 
* m2e-tycho would add the tycho plugin or bundle plugin configuration (TBD) if the PluginNature is present
* m2e-android would add the maven-android-plugin configuration for android projects.
and so on and so forth ...

Note that approach has at least 2 drawbacks :
- that would trigger an early eclipse plugin activation for all plugins contributing converters
- I don't see how this can integrate with the m2e extension discovery mechanism.
Comment 2 Igor Fedorenko CLA 2011-12-31 08:43:16 EST
What component is going to decide if a PDE Bundle project should be converted to a Tycho or a maven-bundle-plugin project? For argument sake, lets assume that m2e/tycho and m2e/maven-bundle-plugin are two separate m2e extensions.

Likewise, what component is going to decide if a project with both PDE Bundle and WTP Dynamic Webapp natures/facets should be converted to a war, a tycho or a maven-bundle-plugin Maven project?
Comment 3 Fred Bricon CLA 2011-12-31 09:48:12 EST
The packaging is already set by the user in the Wizard page. I believe the converters can decide what to do based on that information. 

Before displaying the wizard, we could also pre-set the package based on a IProjectConversionParticipant.guessPackage(IProject) method. If one and only one converter returns a non-null value, then it'd be set as the default package. So if we had the wtp and tycho converters propose war and eclipse-plugin respectively, then the package type would be empty in the wizard, forcing the user to choose a value.
Comment 4 Fred Bricon CLA 2012-01-04 08:48:11 EST
Created attachment 209003 [details]
Proposed patch to implement the feature
Comment 5 Fred Bricon CLA 2012-01-04 08:49:05 EST
Created attachment 209004 [details]
Test cases for project conversion
Comment 6 Igor Fedorenko CLA 2012-01-04 14:19:53 EST
@Fred, as required by [1] can you confirm that:

1. Contains No Cryptography
2. Is Developed from Scratch (without incorporating content from elsewhere)
3. Is 100% Project License Code

and

(a) you wrote 100% of the code;  
(b) that you have the right to contribute the code to Eclipse;  
(c) the file header contains the appropriate License header


[1] http://eclipse.org/legal/EclipseLegalProcessPoster.pdf
Comment 7 Fred Bricon CLA 2012-01-04 15:54:09 EST
I confirm that the contribution :
1. Contains no cryptography.
2. Is developed from scratch. Jboss Tools Maven integration (EPL v1.0 license) contains code that provide a similar feature, but nothing was copied or reused from it.
3. Is 100% Eclipse Public License v1.0 Code.

and
 
(a) I wrote 100% of the code;  
(b) Red Hat has a company wide agreement that authorizes me to contribute the code to Eclipse;  
(c) Modified files retain their existing header. All new files contain the following header  :

/*******************************************************************************
 * Copyright (c) 2012 Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *      Red Hat, Inc. - initial API and implementation
 *******************************************************************************/
Comment 8 Igor Fedorenko CLA 2012-01-08 22:17:57 EST
opened CQ 5947
Comment 9 Igor Fedorenko CLA 2012-01-28 17:38:51 EST
@Fred looks like attached test patch is missing all .project/.classpath/.settings files. Can you please double-check and re-attach proper patch?
Comment 10 Fred Bricon CLA 2012-01-28 19:18:37 EST
Created attachment 210236 [details]
Test cases for project conversion including eclipse settings

Sorry I didn't realize the eclipse files were ignored by git.
Here's a new patch for the test cases.
Comment 11 Igor Fedorenko CLA 2012-01-30 10:55:41 EST
Applied the patches, thank you.
Comment 12 Igor Fedorenko CLA 2012-07-13 08:56:19 EDT
*** Bug 346843 has been marked as a duplicate of this bug. ***
Comment 13 Denis Roy CLA 2021-04-19 13:24:59 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/