Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 76436 - Source Code locations for JAR'ed bundles
Summary: Source Code locations for JAR'ed bundles
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: Build (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: pde-build-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 78525 (view as bug list)
Depends on:
Blocks: 85065 87890
  Show dependency tree
 
Reported: 2004-10-17 01:32 EDT by Wassim Melhem CLA
Modified: 2005-04-14 19:05 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wassim Melhem CLA 2004-10-17 01:32:25 EDT
When dealing with JAR'ed bundles, we need to clearly define where the source 
is going to be located for PDE to be able to:
1. export plugins in this format with/without source.
2. locate and attach source to JARs when computing classpaths.

Here are some initial suggestions that came up in a recent discussion with 
Jeff:
1. If the source is to be packaged inside the JAR alongide the class files, 
they will appear at the root.  This way, the JAR itself can be used as the 
source attachment zip.

2. If the source is shipped separately (i.e. via the pde.core.source extension 
point), then the source zip will appear in the same location as it does now 
but it will be called 'srczip'.  As a quick test to see what PDE/Build 
currently names source zips for bundles with a '.' as a library name, the name 
of the zip is '@dotsrc.zip', which is not a good name.
Comment 1 Pascal Rapicault CLA 2004-10-18 14:59:59 EDT
How do you handle the case 1) for regular plugins?

Why is @dotsrc.zip a problematic name?
Comment 2 Wassim Melhem CLA 2004-10-18 15:15:38 EDT
Regarding 1, as it will appear in tomorrow's I-build, I use the JAR itself as 
the source attachment.  This will only work if the source is at the root of 
the JAR.  
Is that what you do when you build such a JAR with source?  Is this already 
supported by PDE/build?  Is this the story that we are going with?

2. Using @dot as prefix for source zips in just weird :-)  I suggest a 
plain "src.zip".
Comment 3 Wassim Melhem CLA 2004-10-18 17:25:20 EDT
To actually answer Pascal's question re 1., here is how PDE searches for 
source zips for regular plugins:

given a JAR named 'xyz.jar', we first look for a sibling zip file 
named 'xyzsrc.zip'.  If we find it, we attach it.  if not, then we look 
through all the source code locations (i.e. the ones extending the 
pde.core.source extension point), and we look for the zip file 
called 'xyzsrc.zip' that would be located in a com.example.xyz_1.0.0 directory.


Also, I just double-checked with Philippe to see if JDT understands ZIPs 
inside JARs when it comes to source attachments and it is no. 
So as we suspected, when building a JAR'ed bundle with source, the source 
*.java files must remain in a directory structure inside the JAR.

I suggest the *.java files be in a folder called 'src' or the like inside the 
JAR.  This will allow me to figure out quickly if the source is packaged in 
the JAR itself or if I should start looking for it elsewhere.
Comment 4 Pascal Rapicault CLA 2004-10-25 09:29:36 EDT
See discussion bug #76653.
Comment 5 Wassim Melhem CLA 2004-11-12 14:33:29 EST
*** Bug 78525 has been marked as a duplicate of this bug. ***
Comment 6 Wassim Melhem CLA 2004-11-12 14:36:10 EST
To answer Jeff's question regarding where source zips would go if source is 
packaged separately, here is my suggestion:

Suppose the jar'd plugin is org.eclipse.ui, then its source will be in:
<eclipse_install>/org.eclipse.platform_source_3.1.0/src/org.eclipse.ui_3.1.0/sr
c.zip

Note that the source plugins constituting the source features could not be 
JAR'd plugins themselves as we will run into this whole zip in a Jar problem 
with JDT.
Comment 7 Pascal Rapicault CLA 2005-02-21 17:36:50 EST
This has been fixed in the jared_plugins branch
Comment 8 Jeff McAffer CLA 2005-02-21 23:09:56 EST
Note that there is a PDE UI element to this.  DJ was looking at it.  Not sure 
if there is a separate bug.  Adding DJ to the fun
Comment 9 DJ Houghton CLA 2005-02-24 16:07:17 EST
See bug 86561.
Comment 10 Pascal Rapicault CLA 2005-03-09 16:44:04 EST
The branch has been merged back in HEAD.
Comment 11 Wassim Melhem CLA 2005-03-09 16:45:54 EST
question:  do you support exporting a JAR'd plugin with source inside?
Comment 12 Pascal Rapicault CLA 2005-03-10 09:19:31 EST
Common! :-)
Comment 13 Wassim Melhem CLA 2005-03-11 02:48:27 EST
Reopening because the current solution for source inside a JAR that a '.' 
classpath is not good.

If I choose to export such a plugin in a JAR format, a source zip 
named 'src.zip' gets generated at the root of the JAR.  As you know, this is 
useless because JDT does not support this nesting when it comes to source 
attachments (bug 76653).

As suggested in bug 76653, when the source is packaged in this JAR, it has to 
be in unzipped form so that JDT could attach the source when I use the JAR 
itself as its ows source attachment.

It's also better if the source is not at the root of the JAR, but instead in 
a 'src/' subdirectory of the JAR.
Comment 14 Pascal Rapicault CLA 2005-03-11 14:12:12 EST
The problem is real, the solution we can think of now is too complex to be
implemented in a time that would not require us to drop more important features
somewhere else.

Deferring to M7.
Comment 15 Ed Burnette CLA 2005-03-11 14:42:04 EST
Would this work? For a given plugin, say org.eclipse.jface.text_3.1.0.jar, zip
up the source in org.eclipse.jface.text_3.1.0src.zip. The two files would be
siblings in the same directory (plugins). Then if it works as described in
comment #3, PDE would just automatically find the source, right?
Comment 16 Jeff McAffer CLA 2005-03-11 16:23:37 EST
plugins are to be self contained. Either in a dir or a jar.  You could of 
course have a plugin that contains source for another plugin on an individual 
basis.  This may cause undue bloat.  The source lookup mechansim would have to 
be tweaked to know to look in this new place.  

We would not know how to manage having a src zip file sitting around.  For 
example, what would update do with it?
Comment 17 Ed Burnette CLA 2005-04-05 16:04:51 EDT
Just to give you another data point, in our internal build process at SAS we
build each jar twice, one with -g and source code (for developers), one without
(for customers). .java and .class files are intermingled in the same subdirs
inside the developer jar. This is for a closed source product though. I don't
think it would work well for an open source product because it doubles the
builds and administration, and many more people will be using the source.

Most open source projects I've seen always compile with -g and put the source in
a separate archive. Then they have a binary download that has all the jars with
no source, and a source download that has the source only. This is the way
Apache does it and close to the way Eclipse has done it up to now.
Comment 18 Pascal Rapicault CLA 2005-04-14 19:05:02 EDT
Fixed in HEAD.
The fix consists in unzipping the src.zip created by the plugin build script
when the source is gathered in the assemble scripts.