Difference between revisions of "WTP/What we have learned (to love) about P2"

From Eclipsepedia

< WTP
Jump to: navigation, search
(Bugs we've discovered in our code due to P2)
(Can a site be both an update manager site, and a P2 repository?)
 
(7 intermediate revisions by 2 users not shown)
Line 18: Line 18:
 
<pre><nowiki>
 
<pre><nowiki>
 
/M6/eclipse
 
/M6/eclipse
/M6/plugins
+
/M6/eclipse/plugins
/M6/features
+
/M6/eclipse/features
/M6/dropins
+
/M6/eclipse/dropins
/M6/dropins/wtp
+
/M6/eclipse/dropins/wtp
/M6/dropins/emf
+
/M6/eclipse/dropins/emf
/M6/dropins/xsd
+
/M6/eclipse/dropins/xsd
/M6/dropins/.... etc.  
+
/M6/eclipse/dropins/.... etc.  
  
 
And, each of those subdirectories end up looking as they did before ... for example,  
 
And, each of those subdirectories end up looking as they did before ... for example,  
  
/M6/dropins/wtp
+
/M6/eclipse/dropins/wtp
/M6/dropins/wtp/eclipse
+
/M6/eclipse/dropins/wtp/eclipse
/M6/dropins/wtp/eclipse/plugins
+
/M6/eclipse/dropins/wtp/eclipse/plugins
/M6/dropins/wtp/eclipse/features
+
/M6/eclipse/dropins/wtp/eclipse/features
 
</nowiki></pre>
 
</nowiki></pre>
 +
 +
I suspect there will eventually be new bugs open due to increased path lengths. :)
  
 
Now, start eclipse like you usually would. You should have a fully functioning WTP.  
 
Now, start eclipse like you usually would. You should have a fully functioning WTP.  
Line 38: Line 40:
 
This structure has the advantage that it _should_ be easier to update pieces of your install, say just with a new WTP build, without touching the rest of it.  
 
This structure has the advantage that it _should_ be easier to update pieces of your install, say just with a new WTP build, without touching the rest of it.  
  
'''Tip: ''' The first time you start, it'll take a lot longer than it used to. See bug [https://bugs.eclipse.org/bugs/show_bug.cgi?id=224579 224579]. But, subsequent restarts should be as fast or faster -- as long as you do not use -clean (-clean clears the timestamp cache and it goes through the whole re-discover process again).  
+
'''Tip: ''' The first time you start, it'll take a lot longer than it used to. See bug [https://bugs.eclipse.org/bugs/show_bug.cgi?id=224579 224579]. But, subsequent restarts should be as fast or faster -- as long as you do not use -clean (-clean clears the timestamp cache and it goes through the whole re-discover process again).
 +
So, the tip is, don't use -clean routinely (as I used to do) but only if you know you really need it. This should be fixed eventually. (But in fact, we had to remove -clean from all our JUnit tests ... or, else they could not complete in a reasonable amount of time. See bug [https://bugs.eclipse.org/bugs/show_bug.cgi?id=224269 224269]).
  
 
== Self Hosting WTP Development ==  
 
== Self Hosting WTP Development ==  
Line 54: Line 57:
  
 
We have some code which makes assumptions about location of where features are installed. It currently works with P2, but we should never assume anything about features, and may eventually look if there's some P2 API way of accomplishing the update that is being done. See bug [https://bugs.eclipse.org/bugs/show_bug.cgi?id=224441 224441].
 
We have some code which makes assumptions about location of where features are installed. It currently works with P2, but we should never assume anything about features, and may eventually look if there's some P2 API way of accomplishing the update that is being done. See bug [https://bugs.eclipse.org/bugs/show_bug.cgi?id=224441 224441].
 +
 +
== Build and JUnit tests ==
 +
 +
Some changes to our build infrastructure were made, which I'll note here, in case it helps others.
 +
 +
* Compile time: There were not any changes required, which makes sense, but still confused me. The reason is because when we are compiling our code (with JDT) it is not actually running our code (and P2 only has to do installing), and it finds the source where ever we tell it to. This should not change.
 +
 +
* JUnit Test time: We use the Eclipse Platform's test framework -- which for some reason still uses the file system, instead of extensions, to find and run test plugins -- so we had to change some of our infrastructure to unzip into different locations and look for test.xml files in different locations. It turns out, if we'd simply waited until M6 was released, we would not have had to do this ... but, would have still wanted to do it, in order to better test our code, in P2-like conditions.
  
 
== Disabling P2 ==  
 
== Disabling P2 ==  
  
If you just really can't make it work and its interfering with your own development (then, after opening a bug saying so :) ... or, you just want to do some tests comparing the old with the new ... then there is a way to disable P2. See [[Equinox p2 Removal]]. I think only the first three steps listed there are required.
+
Please see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=224908 bug 224908] for scripts and procedures to disable P2.
Of course, this should be a separate install than your P2 attempts, everything unzipped where it used to be, and backups of replaced files kept.  
+
  
I should also warn, that as far as I know, running in this disabled mode has not been extensively tested, though in theory it should all work just fine.
+
== Can a site be both an update manager site, and a P2 repository? ==
  
# Replace the eclipse/configuration/config.ini file with the contents from Eclipse platform version 3.3.2.
+
Yes. We do this for the Ganymede site, but anyone can do it for any site.  
# Replace the eclipse/eclipse.ini file with the contents from Eclipse platform version 3.3.2. <br />If you have none handy, you can try unzipping this zip file ([[Image:NOP2config.zip]]) that has the above two files laid out to over write those two config and ini files.  
+
 
# Remove the platform.xml from eclipse/configuration/org.eclipse.update/platform.xml. (to force re-discovery).
+
This does, however, lead to slightly different appearance, or behavior depending on if you use, or not,
 +
the explicit 'site.xml' at the end of the update site URL.
 +
 
 +
I found this comment from John Arthorne, in [https://bugs.eclipse.org/bugs/show_bug.cgi?id=236142 bug 236142]
 +
to be very helpful in understand why this is and it can help guide site creators in making their choices.
 +
<pre><nowiki>
 +
------ Comment  #4 From John Arthorne  2008-06-06 17:26:04 -0400  [reply] -------
 +
 
 +
Since you have both a content.jar and a site.xml at that location, you actually
 +
have two repositories. You have a classic update site, and a p2 repository
 +
(these files don't know/care about each other).  Classic update sites don't
 +
contain a site name (site.xml has no name element), so these sites are
 +
"nameless". p2 repositories contain a name element so they have a
 +
human-readable name. 
 +
 
 +
You should typically see the same categories in both cases if the content.jar
 +
was built directly from the site.xml at the same location. I'm not sure why
 +
you're seeing a difference here.
 +
 
 +
If you just specify the directory as the URL (such as
 +
http://download.eclipse.org/releases/ganymede/), we have to guess which
 +
repository you meant (either site.xml or content.jar). Our guessing algorithm
 +
first looks for a content.jar or a content.xml, and if found it loads that p2
 +
repository. If there is neither, it looks for site.xml and loads a classic
 +
update site.
 +
</nowiki></pre>
  
 
== References ==
 
== References ==
Line 72: Line 107:
 
* [[Equinox_p2_Getting_Started#Dropins|Equinox p2 - Getting Started with Dropins]]
 
* [[Equinox_p2_Getting_Started#Dropins|Equinox p2 - Getting Started with Dropins]]
 
* [[Equinox_p2_tests|Equinox p2 Testcases]]
 
* [[Equinox_p2_tests|Equinox p2 Testcases]]
 +
 +
[[Category:Eclipse Web Tools Platform Project]]
 +
[[Category:Equinox_p2]]

Latest revision as of 03:48, 9 June 2008

Well, the "love" part might be premature :) but are confident we'll end up there.

This page is a central place to document some notes about what we in WTP have learned about P2, which bugs effect us, little "tricks", etc. Warning: this is a fast evolving area, due to bugs, miscommunication, and ignorance, so take these notes as hints ... nothing is forever ... and update this page as you find more information or errors in the information here.

Contents

[edit] Intro

In theory, shouldn't effect you at all. You could or should be able to do things as always, except there might be some bugs, and there are reasons to try to make use of it. One reason is to help the platform find bugs early so they get fixed by their release. Closer to home ... help find bugs in _our_ code that only show up in the conditions encouraged by P2.

Ever wonder what P2 stands for? As best I can tell "Provisioning Platform" (I think I know why they did not want to call it PP ). We in WTP won't be taking advantage of the platform aspects of it directly (that is, not using their APIs) but its my understanding that the EPP Project will be making their "all in one" installs using P2, which should be much better then the old Update Manager.

[edit] Running WTP

Here's one way to create a running version of WTP. Unzip the Eclipse SDK in some directory, say /M6. You'll see the familiar directories, eclipse/plugins and eclipse/features but some new ones too ... the main new one is an empty directory called eclipse/dropins. This is by design the place to "drop in" other zip files or plugins that are not installed via the P2 User Interface.

I unzip wtp-sdk and all our pre-reqs into separate subdirectories, such as wtp, emf, xsd, gef, dtp, relengtool, testFramework. So ... you end up with a hierarchy similar to

/M6/eclipse
/M6/eclipse/plugins
/M6/eclipse/features
/M6/eclipse/dropins
/M6/eclipse/dropins/wtp
/M6/eclipse/dropins/emf
/M6/eclipse/dropins/xsd
/M6/eclipse/dropins/.... etc. 

And, each of those subdirectories end up looking as they did before ... for example, 

/M6/eclipse/dropins/wtp
/M6/eclipse/dropins/wtp/eclipse
/M6/eclipse/dropins/wtp/eclipse/plugins
/M6/eclipse/dropins/wtp/eclipse/features

I suspect there will eventually be new bugs open due to increased path lengths. :)

Now, start eclipse like you usually would. You should have a fully functioning WTP.

This structure has the advantage that it _should_ be easier to update pieces of your install, say just with a new WTP build, without touching the rest of it.

Tip: The first time you start, it'll take a lot longer than it used to. See bug 224579. But, subsequent restarts should be as fast or faster -- as long as you do not use -clean (-clean clears the timestamp cache and it goes through the whole re-discover process again). So, the tip is, don't use -clean routinely (as I used to do) but only if you know you really need it. This should be fixed eventually. (But in fact, we had to remove -clean from all our JUnit tests ... or, else they could not complete in a reasonable amount of time. See bug 224269).

[edit] Self Hosting WTP Development

With the above install, you can use the plugins you normally develop and commit and it will "compile and run against" that version you are self hosting on. (If trouble, go to PDE Preferences, Target Platform, and press "reset" (not reload). Check on "show by location" and you should see all your sub-directories in dropins. (If not, open a bug, or comment in this instructions, or both).

I think there are issues with running against a completely different target, installed in a different directory (see bug 225148). Even that can be worked around by "running" the target, so all the meta data is updated. But, check the bug ... that may change with more information. Maybe it's just me. :) Or, update the bug if you find out more!


[edit] Bugs we've discovered in our code due to P2

My guess is others have similar bugs, so hopefully other projects and adopters can learn from us. These bugs all had to do with making incorrect assumptions about the locations of where things were installed.

One bug was some old pre-osgi-bundle code (that had been copied several places) assumed some things about the name and length of the "eclipse/plugins" directory. These were easy to fix using the correct APIs. See bug 224148.

We have some code which makes assumptions about location of where features are installed. It currently works with P2, but we should never assume anything about features, and may eventually look if there's some P2 API way of accomplishing the update that is being done. See bug 224441.

[edit] Build and JUnit tests

Some changes to our build infrastructure were made, which I'll note here, in case it helps others.

  • Compile time: There were not any changes required, which makes sense, but still confused me. The reason is because when we are compiling our code (with JDT) it is not actually running our code (and P2 only has to do installing), and it finds the source where ever we tell it to. This should not change.
  • JUnit Test time: We use the Eclipse Platform's test framework -- which for some reason still uses the file system, instead of extensions, to find and run test plugins -- so we had to change some of our infrastructure to unzip into different locations and look for test.xml files in different locations. It turns out, if we'd simply waited until M6 was released, we would not have had to do this ... but, would have still wanted to do it, in order to better test our code, in P2-like conditions.

[edit] Disabling P2

Please see bug 224908 for scripts and procedures to disable P2.

[edit] Can a site be both an update manager site, and a P2 repository?

Yes. We do this for the Ganymede site, but anyone can do it for any site.

This does, however, lead to slightly different appearance, or behavior depending on if you use, or not, the explicit 'site.xml' at the end of the update site URL.

I found this comment from John Arthorne, in bug 236142 to be very helpful in understand why this is and it can help guide site creators in making their choices.

------ Comment  #4 From John Arthorne  2008-06-06 17:26:04 -0400  [reply] -------

Since you have both a content.jar and a site.xml at that location, you actually
have two repositories. You have a classic update site, and a p2 repository
(these files don't know/care about each other).  Classic update sites don't
contain a site name (site.xml has no name element), so these sites are
"nameless". p2 repositories contain a name element so they have a
human-readable name.  

You should typically see the same categories in both cases if the content.jar
was built directly from the site.xml at the same location. I'm not sure why
you're seeing a difference here.

If you just specify the directory as the URL (such as
http://download.eclipse.org/releases/ganymede/), we have to guess which
repository you meant (either site.xml or content.jar). Our guessing algorithm
first looks for a content.jar or a content.xml, and if found it loads that p2
repository. If there is neither, it looks for site.xml and loads a classic
update site.

[edit] References