Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » How to: create DWP programmatically? (Creation of dynamic web project using api)
How to: create DWP programmatically? [message #667985] Tue, 03 May 2011 08:36 Go to next message
Prasanna K is currently offline Prasanna KFriend
Messages: 78
Registered: July 2009
Member
Need to create Dynamic Web Project from the plug-in programmatically, given the file system paths to sources (webcontent dir) and jars, the project depends on.
How do I go about doing this?

Google search led me to eclipse-tips blog post: http://blog.eclipse-tips.com/2008/10/faceted-project-framewo rk.html

Looked for api reference (javadoc) of org.eclipse.wst.common.project.facet.core.IFacetedProject
on the web but didn't find any.

Please guide.

Thanks.
Re: How to: create DWP programmatically? [message #668192 is a reply to message #667985] Wed, 04 May 2011 12:42 Go to previous messageGo to next message
Prasanna K is currently offline Prasanna KFriend
Messages: 78
Registered: July 2009
Member
Created a dwp manually using eclipse.
Tried to create a dwp programmatically so that its .project matches that of created by Eclipse.
Project gets created fine. (both .project files are same).

But there is no .classpath file in the project dir.
Also I'm not able to link the sources and add external jars to classpath. When I link the sources, the package structure doesn't match the one on the disk.

Here is the code (thus far):
private void createDWP(IProject project) throws CoreException {
    IFacetedProject facetedProject =
                    ProjectFacetsManager.create(project, true, null);
    IProjectDescription description = project.getDescription();
    description.setNatureIds(new String[]
            {"org.eclipse.jem.workbench.JavaEMFNature",
            "org.eclipse.jdt.core.javanature",
            "org.eclipse.wst.common.project.facet.core.nature",
            "org.eclipse.wst.common.modulecore.ModuleCoreNature",
            "org.eclipse.wst.jsdt.core.jsNature"});
    project.setDescription(description, null);
    IProjectFacet wstWebFacet = ProjectFacetsManager.getProjectFacet
                    (IModuleConstants.WST_WEB_MODULE);
    facetedProject.installProjectFacet
                    (wstWebFacet.getDefaultVersion(), null, null);
}



How does one add source and lib entries to a DynamicWebProject (facetedproject) programmatically?
Please guide.
Re: How to: create DWP programmatically? [message #870971 is a reply to message #668192] Thu, 10 May 2012 12:02 Go to previous message
Raj V is currently offline Raj VFriend
Messages: 4
Registered: May 2012
Junior Member
Hi,

I'm also trying to create the dynamic web project using RSA plugins, but my code is getting failed. Could you please share your code to generate dynamic web project...

Below is the code which i'm using:

IDataModel dm = DataModelFactory.createDataModel(new SimpleWebFacetProjectCreationDataModelProvider());
		dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projectName); //$NON-NLS-1$
		FacetDataModelMap facetDataModelMap = (FacetDataModelMap) dm
				.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
		
		
		IDataModel webFacetDataModel = facetDataModelMap.getFacetDataModel(IModuleConstants.WST_WEB_MODULE/*IModuleConstants.JST_WEB_MODULE*/);
		
		webFacetDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION,
				ProjectFacetsManager.getProjectFacet(
						IModuleConstants.WST_WEB_MODULE).getVersion("2.4"));
		dm.getDefaultOperation().execute(null, null);
		IFacetedProject project = ProjectFacetsManager.create(ResourcesPlugin.getWorkspace().getRoot().getProject(
				projectName));



The error that i'm getting is:
java.lang.IllegalArgumentException: Could not find version 2.4 of project facet wst.web.
	at org.eclipse.wst.common.project.facet.core.internal.ProjectFacet.getVersion(ProjectFacet.java:125)




Thanks in adavance.
Raj
Previous Topic:JavaScript auto completion according to variable type
Next Topic:400 Bad Request
Goto Forum:
  


Current Time: Wed Nov 26 05:47:24 GMT 2014

Powered by FUDForum. Page generated in 0.02726 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software