Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » ATTN: Konstantin - FlexibleProjectContainer.java changes from 1.34 to 1.36
ATTN: Konstantin - FlexibleProjectContainer.java changes from 1.34 to 1.36 [message #229894] Tue, 31 March 2009 15:19 Go to next message
Yen Lu is currently offline Yen Lu
Messages: 5
Registered: July 2009
Junior Member
This is a continuation of the discussion between Konstantin and myself in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269360. We have a scenario
where we need to obtain the classpath of a project and filter out certain
entries to improve performance of a third party library that we call.
Here's the code:

IJavaProject project = ...;
IClasspathEntry[] entries = project.getRawClasspath();
...

When the project is a dynamic Web project, there could be entries of type
WebAppLibrariesContainer or J2EEComponentClasspathContainer. For such
entries, we do:

IPackageFragmentRoot[] pkgFragmentRoots =
project.findPackageFragmentRoots(entry);
...
Looping through pkgFragmentRoots, some of the entries we encounter might
be jar libraries in WEB-INF/lib of the dynamic Web module.

With WTP 3.0.4, the getPath() method for a pkgFragmentRoot for a jar
library under WEB-INF/lib returns a path relative to the workspace (e.g.
/project/WebContent/WEB-INF/lib/foo.jar). With the recent changes, 1.36,
now produces a path that is absolute to the filesystem (e.g.
g:/myworkspace/project/WebContent/WEB-INF/lib/foo.jar).

After the discussion, I continued to investigate and found that
pkgFragmentRoot's isExternal() method is now returning true for jars under
WEB-INF/lib now too. This seems incorrect since the files are in the
workspace.

Konstantin, you mentioned some new features coming in - classpath tags.
One would expect these classpath entries to be picked up by the call to
getRawClasspath(). Could you confirm or point me to more information about
this feature? Also, please comment on the change in behavior of
isExternal().

Thanks,
Yen Lu
Re: ATTN: Konstantin - FlexibleProjectContainer.java changes from 1.34 to 1.36 [message #229911 is a reply to message #229894] Wed, 01 April 2009 17:56 Go to previous message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
> With WTP 3.0.4, the getPath() method for a pkgFragmentRoot for a jar
> library under WEB-INF/lib returns a path relative to the workspace (e.g.
> /project/WebContent/WEB-INF/lib/foo.jar). With the recent changes, 1.36,
> now produces a path that is absolute to the filesystem (e.g.
> g:/myworkspace/project/WebContent/WEB-INF/lib/foo.jar).
>
> After the discussion, I continued to investigate and found that
> pkgFragmentRoot's isExternal() method is now returning true for jars under
> WEB-INF/lib now too. This seems incorrect since the files are in the
> workspace.

I would recommend that you follow with JDT on this. I would venture to
guess that you expectation of what "external" means in this context is not
in alignment with theirs. Behavior of this API is not something that WTP
has any control over.

> Konstantin, you mentioned some new features coming in - classpath tags.
> One would expect these classpath entries to be picked up by the call to
> getRawClasspath(). Could you confirm or point me to more information about
> this feature?

You misunderstood me. The ability to tag arbitrary classpath entries for
packaging in WEB-INF/lib (on publish and on archive export) has been a
feature of WTP for several years now.

Try this...

Define a user library that points to a couple of jars. Add the user
library to a web project's build path. Now go to the Java EE Module
Dependencies page in the web project's properties. You will see your user
library listed under Web Libraries. Check the checkbox next to it. Close
the properties page.

Export the war. What do you see in the exported WAR's WEB-INF/lib
directory?

The tags are tracked in the .classpath file. Take a look in that file.

The point that I was trying to make is that if you are assuming that by
focusing on the Web App Libraries container you are getting the complete
picture of what will be in the web app's WEB-INF/lib directory you are
missing important scenarios. Both publishers and war export routines in
WTP include quite sophisticated logic that you would have to duplicate to
do what you are trying to do.

My recommendation is to start with getResolvedClasspath() and then
selectively exclude entries that you know you don't care about. Since all
you are trying to do is optimization, this would be a much safer approach
than what you are doing right now.
Previous Topic:change XML schema prefix impossible using WTP XML model
Next Topic:My First web Application & EJB
Goto Forum:
  


Current Time: Fri Aug 22 12:02:28 EDT 2014

Powered by FUDForum. Page generated in 0.01771 seconds