protected void configure(IProject project, MavenProject mavenProject, IProgressMonitor monitor)
throws CoreException {
monitor.setTaskName(NLS.bind(Messages.EarProjectConfiguratorDelegate_Configuring_EAR_Project,project.getName()));
IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project.getFile(IMavenConstants.POM_FILE_NAME), true, monitor);
EarPluginConfiguration config = new EarPluginConfiguration(mavenProject);
Set<Action> actions = new LinkedHashSet<Action>();
String contentDir = config.getEarContentDirectory(project);
contentDir = PathUtil.toPortablePath(contentDir);
IFolder contentFolder = project.getFolder(contentDir);
ResourceCleaner fileCleaner = new ResourceCleaner(project);
addFoldersToClean(fileCleaner, facade);
fileCleaner.addFiles(contentFolder.getFile("META-INF/application.xml").getProjectRelativePath()); //$NON-NLS-1$
IProjectFacetVersion earFv = config.getEarFacetVersion();
if(!facetedProject.hasProjectFacet(WTPProjectsUtil.EAR_FACET)) {
removeConflictingFacets(facetedProject, earFv, actions);
actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL, earFv, getEarModel(contentDir)));
} else {
//MECLIPSEWTP-37 : don't uninstall the EAR Facet, as it causes constraint failures when used with RAD
IProjectFacetVersion projectFacetVersion = facetedProject.getProjectFacetVersion(WTPProjectsUtil.EAR_FACET);
if(earFv.getVersionString() != null && !earFv.getVersionString().equals(projectFacetVersion.getVersionString())){
actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.VERSION_CHANGE, earFv, getEarModel(contentDir)));
}
}
try {
if(!actions.isEmpty()) {
facetedProject.modify(actions, monitor);
}
}
finally {
try {
//Remove any WTP created files (extra application.xml and manifest)