Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 277504

Summary: Using -destination flag, get p2.core.ProvisionException: Need to set the destination artifact repository location.
Product: [Eclipse Project] Equinox Reporter: Nick Boldt <nboldt>
Component: p2Assignee: P2 Inbox <equinox.p2-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aniefer, pascal
Version: 3.5Flags: dj.houghton: review+
pascal: review+
john.arthorne: review+
Target Milestone: 3.5 RC3   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
script to run repo2runnable and create an all-in-one zip; works in Eclipse VM but not in a separate VM
none
patch none

Description Nick Boldt CLA 2009-05-22 12:58:26 EDT
Created attachment 136827 [details]
script to run repo2runnable and create an all-in-one zip; works in Eclipse VM but not in a separate VM

The attached script works great if you run the "runInEclipse" target with "Run in the same JRE as the workspace" set on the launch config.

However, trying to run it in a different VM (ie., commandline) yields this error:

runInAnt:
No public execute() in class org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable

BUILD FAILED
/home/nboldt/eclipse/workspace-jboss/org.eclipse.dash.common.releng_HEAD/tools/scripts/p2repoFormatToRunnableSDKFormat.xml:14: No public execute() in class org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable

Could a public method be added? Or is this task meant to be called by some other task wrapper? Or could an antlib.xml file be added into the org.eclipse.equinox.p2.repository.tools_*.jar, so these tasks are accessible outside an OSGi environment that knows how to read and resolve plugin.xml files?
Comment 1 Andrew Niefer CLA 2009-05-22 13:24:41 EDT
The class that implements the task is org.eclipse.equinox.p2.internal.repository.tools.tasks.Repo2RunnableTask

However, regardless of that, this task will not work outside of an OSGi environment.  It uses a p2 engine operation, repositories are managed both through OSGi services and through the plugin registry.  For this to work outside of OSGi you are essentially asking for most of the core of p2 to work outside of OSGi.

Comment 2 Nick Boldt CLA 2009-05-22 15:55:18 EDT
Fair enough. So is there a way to run it headless? If I do this:

./eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable

I get this:

org.eclipse.equinox.internal.provisional.p2.core.ProvisionException: Need to set the destination artifact repository location.

What's the syntax for specifying <repository> and <source> on the commandline?
Comment 3 Andrew Niefer CLA 2009-05-22 16:10:21 EDT
There are "-source" and "-destination" arguments.  You should be able to specify multiple -source repos.  The -destination should get used for both metadata and artifacts.

Comment 4 Nick Boldt CLA 2009-05-22 17:11:49 EDT
None of these work, whether the destination dir exists or not:

 /home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -source file://tmp/GEF-Update-3.4.2.zip -destination /tmp/tmp-unpacked
 /home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -source file://tmp/GEF-Update-3.4.2.zip -destination file:/tmp/tmp-unpacked
  /home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -source file://tmp/GEF-Update-3.4.2.zip -destination file://tmp/tmp-unpacked
Comment 5 Andrew Niefer CLA 2009-05-22 17:26:22 EDT
file://tmp/GEF-Update-3.4.2.zip is not a proper repo URL.  For a zip you will need something more like "jar:file:/tmp/GEF-Update-3.4.2.zip!/"  (assuming there is no "eclipse" folder in the root of the zip).
Comment 6 Nick Boldt CLA 2009-05-22 17:41:03 EDT
(In reply to comment #5)
> file://tmp/GEF-Update-3.4.2.zip is not a proper repo URL.  For a zip you will
> need something more like "jar:file:/tmp/GEF-Update-3.4.2.zip!/"  (assuming
> there is no "eclipse" folder in the root of the zip).

Nope.

$ /home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -source jar:file:/tmp/GEF-Update-3.4.2.zip/home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -ll -destination file:/tmp/tmp-unpacked

yields:

org.eclipse.equinox.internal.provisional.p2.core.ProvisionException: Malformed reference to remote file: jar:file:/tmp/GEF-Update-3.4.2.zip/home/nboldt/eclipse/eclipse/eclipse/content.xml
Caused by: java.lang.NullPointerException: no !/ in spec

org.eclipse.equinox.internal.provisional.p2.core.ProvisionException: Need to set the destination artifact repository location.

Comment 7 Nick Boldt CLA 2009-05-22 17:47:38 EDT
Correction. The ! works if you escape it:

/home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -source jar:file:/tmp/GEF-Update-3.4.2.zip\!/ -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -destination file://tmp/tmp-unpacked

but I still get:

org.eclipse.equinox.internal.provisional.p2.core.ProvisionException: Need to set the destination artifact repository location.

Wouldn't it be awesome if the error message actually told you HOW to fix the problem, rather than just WHAT the problem was?

Contrast:

"Need to set the destination artifact repository location."

with

"Need to set -destination file:/path/to/artifact/repository"

I'm just sayin'. :)
Comment 8 DJ Houghton CLA 2009-05-23 12:22:08 EDT
http://wiki.eclipse.org/Equinox/p2/Ant_Tasks
Comment 9 DJ Houghton CLA 2009-05-23 12:24:41 EDT
Sorry, closed based on the last email I read, not on the actual comments. :-) The wiki page above lists some of the args.
Comment 10 Nick Boldt CLA 2009-05-23 12:54:23 EDT
(In reply to comment #9)
> Sorry, closed based on the last email I read, not on the actual comments. :-)
> The wiki page above lists some of the args.

Yes, but ant params != commandline flags. 

But, just to prove I'm willing to give the benefit of the doubt, I've tried a couple more attempts, this time using -repository (since that's what's in the wiki'd task examples):

$ /home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -source jar:file:/tmp/GEF-Update-3.4.2.zip\!/ -repository file://tmp/tmp-unpacked

$ /home/nboldt/eclipse/eclipse/eclipse -nosplash -consolelog -application org.eclipse.equinox.p2.repository.repo2runnable -source jar:file:/tmp/GEF-Update-3.4.2.zip\!/ -repository /tmp/tmp-unpacked

Same sesult:

org.eclipse.equinox.internal.provisional.p2.core.ProvisionException: Need to set the destination artifact repository location.

---

Is it too much to ask that you document how this works? Are we really expected to go browse the source? Surely Pascal's request to have people kick the tires here [1] wasn't just for show?

[1] http://lenettoyeur-on-eclipse.blogspot.com/2009/05/p2-call-for-community-testing.html
Comment 11 DJ Houghton CLA 2009-05-25 10:00:28 EDT
Of course documentation will be done. 

*** This bug has been marked as a duplicate of bug 264741 ***
Comment 12 Nick Boldt CLA 2009-05-25 11:15:33 EDT
(In reply to comment #11)
> Of course documentation will be done. 

In the time it takes to tell me you're going to document it, you could have just answered the question, 'what flag do I use to define the "destination artifact repository location"?'

Whereupon *I* would have documented it myself in the wiki, as I've done for other p2 apps. Pay it forward, you'll be rewarded. :)
Comment 13 Andrew Niefer CLA 2009-05-25 11:31:42 EDT
(In reply to comment #12)
> In the time it takes to tell me you're going to document it, you could have
> just answered the question, 'what flag do I use to define the "destination
> artifact repository location"?'


The answer is "I don't know", and I'm sure DJ is in about the same position.  I've always used the ant task.  Comment #3 is what I got from looking at the source code.  If you say -destination doesn't work then I will need to actually debug it to see what is happening.
Comment 14 Nick Boldt CLA 2009-05-25 12:02:07 EDT
Reopening and renaming to reflect the actual problem here, as stated in comment 7:

... -application
org.eclipse.equinox.p2.repository.repo2runnable -destination ...

does not work, throwing this error:

org.eclipse.equinox.internal.provisional.p2.core.ProvisionException: Need to set the destination artifact repository location.
Comment 15 Andrew Niefer CLA 2009-05-25 14:22:00 EDT
Created attachment 137052 [details]
patch
Comment 16 Andrew Niefer CLA 2009-05-27 15:01:58 EDT
patch released.
Both -source and -destination must be proper URLs to the repository (which means jar: urls for zip files).  You can have multiple -source, but it only makes sense to have one -destination.

Note the command line app has no way to distinguish artifact from metadata repos so the URL is treated as both artifacts and metadata.  If the argument is not both metadata and artifact, then there may be an exception.  The ant task allows distinguishing them.