Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (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
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: 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.

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
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[]
    project.setDescription(description, null);
    IProjectFacet wstWebFacet = ProjectFacetsManager.getProjectFacet
                    (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

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
		IDataModel webFacetDataModel = facetDataModelMap.getFacetDataModel(IModuleConstants.WST_WEB_MODULE/*IModuleConstants.JST_WEB_MODULE*/);
		dm.getDefaultOperation().execute(null, null);
		IFacetedProject project = ProjectFacetsManager.create(ResourcesPlugin.getWorkspace().getRoot().getProject(

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(

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

Current Time: Mon Jun 25 00:53:05 GMT 2018

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

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

Back to the top