Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » WST project creation question
WST project creation question [message #230205] Wed, 08 April 2009 22:21 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: WST project creation question [message #230313 is a reply to message #230223] Tue, 14 April 2009 00:28 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Hi Eric,

The runtime modeling component of faceted project framework has no support
for anything equivalent to JDT's Execution Environment concept. When you
target a runtime, you are targeting a specific one. This includes the
specific JRE that is associated with that runtime. This could be an
interesting enhancement for after Galileo.

Now, the no runtime case is a bit special. When no runtime is specified,
facets are free to do what they choose with their classpath. In the case
of the java facet, the current implementation just latches onto the
default vm. Perhaps a better solution would be to latch on to the java
execution environment that corresponds to the facet version. This can
happen for Galileo, but will only benefit users in the no runtime
scenario. Do you want to open an enhancement request for this?

- Konstantin
Previous Topic:Eclipse Pages Validation Question
Next Topic:WTP 3.0.4, JBoss 5.1.0.Beta1, and Web Beans RI (beta)
Goto Forum:
  


Current Time: Tue Apr 16 19:17:20 GMT 2024

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

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

Back to the top