WST project creation question [message #230205] |
Wed, 08 April 2009 22:21 |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
I am using code similar to the following to create a WTP project:
IDataModel model = DataModelFactory.createDataModel((IDataModelProvider)
IWebFacetInstallDataModelProperties._provider_class.newInsta nce());
IFacetedProjectWorkingCopy fpwc = (IFacetedProjectWorkingCopy)
model.getProperty(IFacetProjectCreationDataModelProperties.F ACETED_PROJECT_WORKING_COPY);
IFacetedProjectTemplate template =
ProjectFacetsManager.getTemplate("template.jst.web"); //$NON-NLS-1$
fpwc.setProjectName(projectName);
fpwc.setFixedProjectFacets(template.getFixedProjectFacets()) ;
fpwc.setTargetedRuntimes(Collections.<IRuntime> emptySet());
model.setProperty(IFacetProjectCreationDataModelProperties.F ACET_RUNTIME, fpwc.getPrimaryRuntime());
fpwc.commitChanges(progress);
IProject project = fpwc.getProject();
The problem is, the created project is using the workspace default JRE
on its build path. That is a problem for portability of projects
(export/import, CVS check-in, etc.) so we prefer to use an Execution
Environment instead.
Is there any way to instruct WST to create the project using an
Execution Environment? I know I can explicitly remove the JRE and add an
EE directly, but I was hoping there is a simpler method to get WST to do it.
TIA,
Eric
|
|
|
Re: WST project creation question [message #230223 is a reply to message #230205] |
Thu, 09 April 2009 14:38 |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
On 4/8/2009 6:21 PM, Eric Rizzo wrote:
> I am using code similar to the following to create a WTP project:
>
> IDataModel model = DataModelFactory.createDataModel((IDataModelProvider)
> IWebFacetInstallDataModelProperties._provider_class.newInsta nce());
>
> IFacetedProjectWorkingCopy fpwc = (IFacetedProjectWorkingCopy)
> model.getProperty(IFacetProjectCreationDataModelProperties.F ACETED_PROJECT_WORKING_COPY);
>
> IFacetedProjectTemplate template =
> ProjectFacetsManager.getTemplate("template.jst.web"); //$NON-NLS-1$
>
> fpwc.setProjectName(projectName);
> fpwc.setFixedProjectFacets(template.getFixedProjectFacets()) ;
> fpwc.setTargetedRuntimes(Collections.<IRuntime> emptySet());
> model.setProperty(IFacetProjectCreationDataModelProperties.F ACET_RUNTIME, fpwc.getPrimaryRuntime());
>
> fpwc.commitChanges(progress);
> IProject project = fpwc.getProject();
>
> The problem is, the created project is using the workspace default JRE
> on its build path. That is a problem for portability of projects
> (export/import, CVS check-in, etc.) so we prefer to use an Execution
> Environment instead.
> Is there any way to instruct WST to create the project using an
> Execution Environment? I know I can explicitly remove the JRE and add an
> EE directly, but I was hoping there is a simpler method to get WST to do
> it.
Looks like the code in
org.eclipse.jst.common.project.facet.core.internal.JavaFacet Util.resetClasspath()
is the culprit:
final IVMInstall vm = JavaRuntime.getDefaultVMInstall();
if( vm != null )
{
IPath path = new Path( JavaRuntime.JRE_CONTAINER );
path = path.append( vm.getVMInstallType().getId() );
path = path.append( vm.getName() );
final IClasspathEntry cpe
= JavaCore.newContainerEntry( path );
final List entries = Collections.singletonList( cpe );
ClasspathHelper.addClasspathEntries( project, newver, entries );
}
Based on the fact that it is calling JavaRuntime.getDefaultVMInstall() I
guess I'm out of luck. I was hoping for some way to configure this via
the WST API... any advice?
Eric
|
|
|
|
Powered by
FUDForum. Page generated in 0.03245 seconds