I am trying to convert a java project to a dynamic web project programmatically by adding the required project facets.
Here is my code:
IProjectFacet JAVA_FACET = ProjectFacetsManager.getProjectFacet("jst.java");
IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet("jst.web");
iFacetedProject.installProjectFacet(JAVA_FACET.getVersion("5.0"), null, monitor);
iFacetedProject.installProject开发者_如何学CFacet(WEB_FACET.getVersion("2.4"), null, monitor);
The facets get added correctly and the IDE recognizes the project as a web project. The problem I am seeing is that adding the facets also creates an EAR project which I don't want.
Is there a way to suppress creating an EAR and just adding the facets to my project?
In order to avoid the creation of ear you can try this:
IProjectFacet JAVA_FACET = ProjectFacetsManager.getProjectFacet("jst.java");
IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet("jst.web");
iFacetedProject.installProjectFacet(JAVA_FACET.getVersion("5.0"), null, monitor);
IDataModel aFacetInstallDataModel = DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider());
aFacetInstallDataModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, false);
iFacetedProject.installProjectFacet(WEB_FACET.getVersion("2.4"), aFacetInstallDataModel, monitor);
In the same way, you are able to pass throw the same function a customize ear...
精彩评论