Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » [p2] how to generate "a.jre.javase" IU?
[p2] how to generate "a.jre.javase" IU? [message #502253] Mon, 07 December 2009 13:26 Go to next message
Jan Sievers is currently offline Jan Sievers
Messages: 23
Registered: July 2009
Junior Member
Hi,

looking at content.xml in

http://download.eclipse.org/releases/galileo/content.jar

I find the "special" IU that seems to represent the packages provided by the
JDK:

<unit id='a.jre.javase' version='1.6.0' singleton='false'>

I would need this IU in my p2 repo to be able to satisfy package
requirements for JDK packages for a maven3/tycho build which calculates
dependencies based on p2 metadata.

Any hints on how this IU can be generated using e.g.
FeaturesAndBundlesPublisher?

Thanks and Best Regards
Jan
Re: [p2] how to generate "a.jre.javase" IU? [message #502559 is a reply to message #502253] Tue, 08 December 2009 19:52 Go to previous messageGo to next message
Phil Denis is currently offline Phil Denis
Messages: 26
Registered: October 2009
Junior Member
You cannot use FeaturesAndBundles publisher to do this. Metadata generation was completely refactored.

The "old" EclipseGenerator application used to build a JRE IU in content.xml. However, it should not be used anymore IMHO because it does not process p2.inf (or Advice files). Now this functionality is split across several different IPublisherActions (see attached pic of IPublisherAction's hierarchy). An AbstractPublisherApplication has a method called
IPublisherAction[] createActions()
that specifies what the publisher application will create.

FeaturesAndBundlesPublisher only creates 2 actions .. FeaturesAction and BundlesAction. The code to generate the JRE IU is located in JREAction. To my knowledge, none of the publisher applications that ship with Equinox use the JREAction.

So, to do this you need to create your own publisher application. I have taken FeaturesAndBundlesPublisher and modified it to also create the JRE IU.

package ca.richer.releng.eclipse.updatesite;

import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;

import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.p2.publisher.AbstractPublisherAction;
import org.eclipse.equinox.p2.publisher.AbstractPublisherApplication;
import org.eclipse.equinox.p2.publisher.IPublisherAction;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.actions.JREAction;
import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction;

/**
 * <p>
 * This application generates meta-data and artifact repositories from a set of features and bundles.
 * If -source <localdir> parameter is given, it specifies the directory under which to find the features 
 * and bundles (in the standard "features" and "plugins" sub-directories).
 * </p><p>
 * Optionally, the -features <csv of file locations> and -bundles <csv of file locations> arguments can 
 * be specified.  If given, these override the defaults derived from a supplied -source parameter.
 * </p>
 * 
 ****************************************************************************************************************************** 
 * PHIL: Note, this is essentially a copy of org.eclipse.equinox.p2.publisher.eclipse.FeaturesAndBundlesPublisherApplication,
 * except it also generates the special JRE IU that is necessary for plugins importing extension packages from the jre.
 ****************************************************************************************************************************** 
 */
public class MetadataPublisherApplication extends AbstractPublisherApplication {

	protected File[] features = null;
	protected File[] bundles = null;

	public MetadataPublisherApplication() {
		// nothing to do
	}

	protected void processParameter(String arg, String parameter, PublisherInfo pinfo) throws URISyntaxException {
		super.processParameter(arg, parameter, pinfo);

		if (arg.equalsIgnoreCase("-features")) //$NON-NLS-1$
			features = createFiles(parameter);

		if (arg.equalsIgnoreCase("-bundles")) //$NON-NLS-1$
			bundles = createFiles(parameter);
	} 
 
	private File[] createFiles(String parameter) {
		String[] filespecs = AbstractPublisherAction.getArrayFromString(parameter, ","); //$NON-NLS-1$
		File[] result = new File[filespecs.length];
		for (int i = 0; i < filespecs.length; i++)
			result[i] = new File(filespecs[i]);
		return result;
	}

	protected IPublisherAction[] createActions() {
		ArrayList result = new ArrayList();
		if (features == null)
			features = new File[] {new File(source, "features")}; //$NON-NLS-1$
		result.add(new FeaturesAction(features));
		if (bundles == null)
			bundles = new File[] {new File(source, "plugins")}; //$NON-NLS-1$
		result.add(new BundlesAction(bundles));
                result.add(new JREAction((File) null)); // Phil: Always create the JRE configuration IU[
		return (IPublisherAction[]) result.toArray(new IPublisherAction[result.size()]);
	}
}


Then you can add this application in your plugin.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
	<extension
	      id="MetadataPublisher"
	      point="org.eclipse.core.runtime.applications">
	   <application>
	      <run class="ca.richer.releng.eclipse.updatesite.MetadataPublisherApplication"/>
	   </application> 
	</extension>

</plugin>


Please note, however, that you only need the JRE IU in content.xml if you are trying to install some bundle that uses "extension packages" from the JRE. For example, org.w3c.dom or javax.swing.

Hope this helps,
Phil
Re: [p2] how to generate "a.jre.javase" IU? [message #502560 is a reply to message #502253] Tue, 08 December 2009 19:58 Go to previous message
Phil Denis is currently offline Phil Denis
Messages: 26
Registered: October 2009
Junior Member
Dunno why my pic attachment didn't work, but here's IPublisherAction's hierarchy:

IPublisherAction
--AbstractPublisherAction
----AccumulateConfigDataAction
----ApplicationLauncherAction
----BundlesAction
----ConfigCUsAction
----DefaultCUsAction
----EclipseInstallAction
----EquinoxExecutableAction
----EquinoxLauncherCUAction
----FeaturesAction
------RemoteFeaturesAction
----JREAction
----MergeResultsAction
----ProductsAction
----RootFilesAction
----RootIUAction
----SiteXMLAction
------CategoryXMLAction
----LocalUpdateSiteAction
----RemoteUpdateSiteAction
Previous Topic:Security issue with the Telnet Console
Next Topic:EclipseGenerator vs. FeaturesAndBundlesPublisher
Goto Forum:
  


Current Time: Wed Sep 03 07:18:34 GMT 2014

Powered by FUDForum. Page generated in 0.01580 seconds