Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Knauer2007-10-04 14:22:21 +0000
committerMarkus Knauer2007-10-04 14:22:21 +0000
commitb1247d0610294b19eb96751e2f28fa657cb9e7de (patch)
tree0a3ba59089a5e76b265d2790b6ab37684d46224a /plugins
parent83403988f76525d18466fc7a599751262e3beb7c (diff)
downloadorg.eclipse.epp.packages-b1247d0610294b19eb96751e2f28fa657cb9e7de.tar.gz
org.eclipse.epp.packages-b1247d0610294b19eb96751e2f28fa657cb9e7de.tar.xz
org.eclipse.epp.packages-b1247d0610294b19eb96751e2f28fa657cb9e7de.zip
bug 205414 - removing old installer code; bug 204288 relative paths (modified); removing unnecessary config.ini code
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.epp.packaging.core/plugin.xml6
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Application.java5
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/EclipsePackagingExecutor.java35
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/EclipsePackager.java20
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/InstallerPackager.java83
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IModifiablePackagerConfiguration.java6
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPackagerConfiguration.java4
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java18
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser.java143
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/IXmlElement.java22
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XMLDocument.java46
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XmlElement.java17
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/messages.properties1
13 files changed, 171 insertions, 235 deletions
diff --git a/plugins/org.eclipse.epp.packaging.core/plugin.xml b/plugins/org.eclipse.epp.packaging.core/plugin.xml
index 8467070b..b3afb468 100644
--- a/plugins/org.eclipse.epp.packaging.core/plugin.xml
+++ b/plugins/org.eclipse.epp.packaging.core/plugin.xml
@@ -15,11 +15,11 @@
id="EPP"
point="org.eclipse.core.runtime.products">
<product
- application="org.eclipse.packaging.application"
- name="%product.name">
+ application="org.eclipse.epp.packaging.core.application"
+ name="EPP Packaging">
<property
name="appName"
- value="EPP">
+ value="EPP Packaging">
</property>
</product>
</extension>
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Application.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Application.java
index 99451a06..3c006bf7 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Application.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Application.java
@@ -28,7 +28,10 @@ public class Application implements IPlatformRunnable {
*/
public Object run( final Object args ) throws Exception {
ICommands commands = ArgumentParser.parse( args );
- IPackagerConfiguration configuration = new ConfigurationParser().parseConfiguration( commands.getConfigurationFile() );
+ ConfigurationParser configurationParser
+ = new ConfigurationParser( commands.getConfigurationFile() );
+ IPackagerConfiguration configuration
+ = configurationParser.parseConfiguration( );
new EclipsePackagingExecutor( commands, configuration ).execute();
return EXIT_OK;
}
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/EclipsePackagingExecutor.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/EclipsePackagingExecutor.java
index e6f1734c..e1234541 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/EclipsePackagingExecutor.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/EclipsePackagingExecutor.java
@@ -15,7 +15,6 @@ import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.epp.packaging.core.assembly.EclipsePackager;
import org.eclipse.epp.packaging.core.assembly.IPackager;
-import org.eclipse.epp.packaging.core.assembly.InstallerPackager;
import org.eclipse.epp.packaging.core.assembly.PackageMover;
import org.eclipse.epp.packaging.core.configuration.ICommands;
import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration;
@@ -25,7 +24,10 @@ import org.eclipse.epp.packaging.core.download.IUpdateSiteManager;
import org.eclipse.epp.packaging.core.download.UpdateSiteManager;
import org.eclipse.epp.packaging.core.logging.MessageLogger;
-/**The main class, independent from the creation of the configuration and less dependent on the application/platformrunnable*/
+/**
+ * The main class, independent from the creation of the configuration and less
+ * dependent on the application/platform runnable
+ */
public class EclipsePackagingExecutor {
private final ICommands commands;
@@ -38,18 +40,22 @@ public class EclipsePackagingExecutor {
this.configuration = configuration;
}
- /**Run the packaging process*/
+ /**
+ * Run the packaging process
+ */
public void execute() throws CoreException, IOException {
- MessageLogger.getInstance()
- .log( "Application.FeatureCount", //$NON-NLS-1$
- configuration.getRequiredFeatures().length );
- boolean doCheckOrInstall = commands.mustDo( Task.CHECK )
- || commands.mustDo( Task.INSTALL );
+ MessageLogger logger = MessageLogger.getInstance();
+ logger.log( "Application.FeatureCount", //$NON-NLS-1$
+ Integer.valueOf( this.configuration.getRequiredFeatures().length ) );
+ boolean doCheckOrInstall = this.commands.mustDo( Task.CHECK )
+ || this.commands.mustDo( Task.INSTALL );
if( doCheckOrInstall ) {
- IUpdateSiteManager manager = new UpdateSiteManager( configuration );
- boolean areFeaturesPresent = manager.areFeaturesPresent( configuration.getRequiredFeatures() );
+ IUpdateSiteManager manager
+ = new UpdateSiteManager( this.configuration );
+ boolean areFeaturesPresent
+ = manager.areFeaturesPresent( this.configuration.getRequiredFeatures() );
if( areFeaturesPresent ) {
- if( commands.mustDo( Task.INSTALL ) ) {
+ if( this.commands.mustDo( Task.INSTALL ) ) {
install( manager );
}
build();
@@ -60,13 +66,12 @@ public class EclipsePackagingExecutor {
}
private void build() throws IOException, CoreException {
- if( commands.mustDo( Task.BUILD ) ) {
+ if( this.commands.mustDo( Task.BUILD ) ) {
MessageLogger.getInstance().logBeginProcess( "Application.Building" ); //$NON-NLS-1$
IPackager packager = new EclipsePackager( this.configuration );
packager.packApplication();
PackageMover mover = new PackageMover( this.configuration );
mover.moveFiles();
-// new InstallerPackager( configuration ).packApplication();
MessageLogger.getInstance().logEndProcess();
}
}
@@ -79,7 +84,9 @@ public class EclipsePackagingExecutor {
throws IOException, CoreException
{
MessageLogger.getInstance().logBeginProcess( "Application.Installing" ); //$NON-NLS-1$
- new ExtensionSiteManager( configuration ).installFeatures( manager );
+ ExtensionSiteManager extensionSiteManager
+ = new ExtensionSiteManager( this.configuration );
+ extensionSiteManager.installFeatures( manager );
MessageLogger.getInstance().logEndProcess();
}
}
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/EclipsePackager.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/EclipsePackager.java
index 3cef849d..d54e02b4 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/EclipsePackager.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/EclipsePackager.java
@@ -26,7 +26,6 @@ import org.eclipse.update.core.VersionedIdentifier;
public class EclipsePackager implements IPackager {
private static final String CONFIGURED_FEATURES_ZIP = "ConfiguredFeatures.zip"; //$NON-NLS-1$
- private static final String CONFIG_INI_ZIP = "ConfigIni.zip"; //$NON-NLS-1$
private final PackagerRunner runner;
/**
@@ -44,7 +43,7 @@ public class EclipsePackager implements IPackager {
prepareWorkingArea( configuration );
}
- /** Creates the map file in the workspace and clears the existing workarea. */
+ /** Creates the map file in the workspace and clears the existing work area. */
private void prepareWorkingArea( final IPackagerConfiguration configuration )
throws IOException
{
@@ -68,8 +67,6 @@ public class EclipsePackager implements IPackager {
writeDataForCustomFile( CONFIGURED_FEATURES_ZIP,
mapWriter,
propertiesWriter );
- zipConfig( sourceFolder, configuration );
- writeDataForCustomFile( CONFIG_INI_ZIP, mapWriter, propertiesWriter );
mapWriter.close();
propertiesWriter.close();
customTargetsWriter.close();
@@ -80,20 +77,7 @@ public class EclipsePackager implements IPackager {
final PackagingPropertiesWriter propertiesWriter )
{
mapWriter.addCustomFileForAllPlatforms( filename );
-// propertiesWriter.addFileToOrder( filename );
- }
-
- private void zipConfig( final File parentFolder,
- final IPackagerConfiguration configuration )
- throws IOException
- {
- String canonicalPath = configuration.getConfigIni().getCanonicalPath();
- MessageLogger.getInstance().log( "EclipsePackager.InjectIni", //$NON-NLS-1$
- canonicalPath );
- Zip zip = new Zip( parentFolder, CONFIG_INI_ZIP );
- zip.addFileAs( configuration.getConfigIni(),
- "eclipse/configuration/config.ini" ); //$NON-NLS-1$
- zip.close();
+ propertiesWriter.addFileToOrder( filename );
}
/**
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/InstallerPackager.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/InstallerPackager.java
deleted file mode 100644
index d365fc3c..00000000
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/InstallerPackager.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Innoopract Informationssysteme GmbH
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Innoopract - initial API and implementation
- *******************************************************************************/
-package org.eclipse.epp.packaging.core.assembly;
-
-import java.io.IOException;
-
-import org.eclipse.ant.core.AntRunner;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration;
-import org.eclipse.epp.packaging.core.configuration.IPlatform;
-
-/**
- * An IPackager to interface with the Instantiations-contributed installer
- * framework.
- */
-public class InstallerPackager implements IPackager {
-
- private static final String INSTALLER_PLUGIN_ID = "com.instantiations.installer"; //$NON-NLS-1$
- private final IPackagerConfiguration configuration;
-
- /**
- * TODO mknauer missing doc
- * @param configuration
- */
- public InstallerPackager( final IPackagerConfiguration configuration ) {
- this.configuration = configuration;
- }
-
- /**
- * Creates the installers. Requires the packager-generated archives to be
- * present as input source.
- */
- public void packApplication() throws IOException, CoreException {
- for( IPlatform platform : this.configuration.getTargetPlatforms() ) {
- AntRunner runner = new AntRunner();
- runner.setBuildFileLocation( getBuildScript( platform ) );
- System.setProperty( "build.root", //$NON-NLS-1$
- this.configuration.getTargetFolder().getAbsolutePath() );
- System.setProperty( "product.name", //$NON-NLS-1$
- "Install-" //$NON-NLS-1$
- + platform.getTargetFileName( this.configuration ) );
- System.setProperty( "install.tools", //$NON-NLS-1$
- PluginUtils.getPluginPath( INSTALLER_PLUGIN_ID )
- + "/" ); //$NON-NLS-1$
- System.setProperty( "install.image", //$NON-NLS-1$
- this.configuration.getTargetFolder() + "/" //$NON-NLS-1$
- + platform.getTargetFileName( this.configuration )
- + platform.getArchiveFormat().getExtension() );
- runner.setExecutionTargets( new String[]{
- getAntTarget( platform )
- } );
- runner.run();
- }
- }
-
- private String getAntTarget( final IPlatform platform ) {
- String target = null;
- switch( platform.getArchiveFormat() ) {
- case antZip: {
- target = "build_installer_from_zip"; //$NON-NLS-1$
- break;
- }
- case tar: {
- target = "build_installer_from_tar"; //$NON-NLS-1$
- break;
- }
- }
- return target;
- }
-
- private String getBuildScript( final IPlatform platform ) {
- String folder = this.configuration.getInstallerConfigurationFolder() + "/"; //$NON-NLS-1$
- return folder + platform.getInstallScriptName();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IModifiablePackagerConfiguration.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IModifiablePackagerConfiguration.java
index de5a6ce6..149f644d 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IModifiablePackagerConfiguration.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IModifiablePackagerConfiguration.java
@@ -48,12 +48,6 @@ public interface IModifiablePackagerConfiguration
/**Sets the folder containing the RCP root files.*/
public void setRootFileFolder( final String folderName );
- /**Sets the config.ini file to use.*/
- public void setConfigIni( final String fileName );
-
/**Sets the product name to use for the final result.*/
public void setProductName( final String name );
-
- /**Sets the folder containing the configuration files for the installer.*/
- public void setInstallerConfigurationFolder( final String folder );
} \ No newline at end of file
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPackagerConfiguration.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPackagerConfiguration.java
index bcd9d089..178eb698 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPackagerConfiguration.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPackagerConfiguration.java
@@ -25,8 +25,6 @@ public interface IPackagerConfiguration {
public File getPackagerConfigurationFolder();
- public String getInstallerConfigurationFolder();
-
public File getTargetFolder();
public File getExtensionSite();
@@ -37,8 +35,6 @@ public interface IPackagerConfiguration {
public File getRootFileFolder();
- public File getConfigIni();
-
public String getProductName();
public String getEclipseProductId();
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java
index f79523c4..e10dc5e1 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java
@@ -33,11 +33,9 @@ public class PackagerConfiguration implements IModifiablePackagerConfiguration {
private File extensionSite;
private String rcpVersion;
private File rootFolder;
- private File configIni;
private String productName;
private String eclipseProductId;
private String initialPerspectiveId;
- private String installerConfigurationFolder;
public PackagerConfiguration() {
this.baseFolder = org.eclipse.core.runtime.Platform.getLocation().toFile();
@@ -111,14 +109,6 @@ public class PackagerConfiguration implements IModifiablePackagerConfiguration {
this.rootFolder = new File( folderName );
}
- public File getConfigIni() {
- return this.configIni;
- }
-
- public void setConfigIni( final String fileName ) {
- this.configIni = new File( fileName );
- }
-
public void setProductName( final String name ) {
this.productName = name;
}
@@ -127,14 +117,6 @@ public class PackagerConfiguration implements IModifiablePackagerConfiguration {
return this.productName;
}
- public String getInstallerConfigurationFolder() {
- return this.installerConfigurationFolder;
- }
-
- public void setInstallerConfigurationFolder( final String folder ) {
- this.installerConfigurationFolder = folder;
- }
-
public void setEclipseProductId( final String eclipseProductId ) {
this.eclipseProductId = eclipseProductId;
}
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser.java
index f014067c..76300847 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser.java
@@ -27,38 +27,44 @@ import org.xml.sax.SAXException;
public class ConfigurationParser {
private static final String ATTRIB_ARCH = "arch"; //$NON-NLS-1$
+// private static final String ATTRIB_CONFIG_INI = "configIni"; //$NON-NLS-1$
+ private static final String ATTRIB_ECLIPSE_INI_PATH = "path"; //$NON-NLS-1$
+ private static final String ATTRIB_ECLIPSE_PRODUCT_ID = "eclipseProductId"; //$NON-NLS-1$
private static final String ATTRIB_FOLDER = "folder"; //$NON-NLS-1$
private static final String ATTRIB_FORMAT = "format"; //$NON-NLS-1$
private static final String ATTRIB_ID = "id"; //$NON-NLS-1$
+ private static final String ATTRIB_INITIAL_PERSPECTIVE_ID = "initialPerspectiveId"; //$NON-NLS-1$
+ private static final String ATTRIB_NAME = "name"; //$NON-NLS-1$
private static final String ATTRIB_OS = "os"; //$NON-NLS-1$
private static final String ATTRIB_RELATIVE_FOLDER = "relativeFolder"; //$NON-NLS-1$
private static final String ATTRIB_URL = "url"; //$NON-NLS-1$
private static final String ATTRIB_VERSION = "version"; //$NON-NLS-1$
private static final String ATTRIB_WS = "ws"; //$NON-NLS-1$
+
private static final String TAG_ARCHIVE_FORMAT = "archiveFormat"; //$NON-NLS-1$
+ private static final String TAG_ECLIPSE_INI_FILE = "eclipseIniFileContent"; //$NON-NLS-1$
private static final String TAG_EXTENSION_SITE = "extensionSite"; //$NON-NLS-1$
private static final String TAG_FEATURE = "feature"; //$NON-NLS-1$
private static final String TAG_PACKAGER_CONFIGURATION_FOLDER = "packagerConfigurationFolder"; //$NON-NLS-1$
- private static final String TAG_INSTALLER_CONFIGURATION_FOLDER = "installerConfigurationFolder"; //$NON-NLS-1$
private static final String TAG_PLATFORM = "platform"; //$NON-NLS-1$
+ private static final String TAG_PRODUCT = "product"; //$NON-NLS-1$
private static final String TAG_RCP = "rcp"; //$NON-NLS-1$
private static final String TAG_REQUIRED_FEATURES = "requiredFeatures"; //$NON-NLS-1$
private static final String TAG_ROOT_FILE_FOLDER = "rootFileFolder"; //$NON-NLS-1$
private static final String TAG_TARGET_PLATFORMS = "targetPlatforms"; //$NON-NLS-1$
private static final String TAG_UPDATE_SITE = "updateSite"; //$NON-NLS-1$
private static final String TAG_UPDATE_SITES = "updateSites"; //$NON-NLS-1$
- private static final String TAG_PRODUCT = "product"; //$NON-NLS-1$
- private static final String ATTRIB_CONFIG_INI = "configIni"; //$NON-NLS-1$
- private static final String ATTRIB_NAME = "name"; //$NON-NLS-1$
- private static final String ATTRIB_ECLIPSE_PRODUCT_ID = "eclipseProductId"; //$NON-NLS-1$
- private static final String ATTRIB_INITIAL_PERSPECTIVE_ID = "initialPerspectiveId"; //$NON-NLS-1$
- private static final String TAG_ECLIPSE_INI_FILE = "eclipseIniFileContent"; //$NON-NLS-1$
- private static final String ATTRIB_ECLIPSE_INI_PATH = "path"; //$NON-NLS-1$
+ private final File xmlFile;
+
+ public ConfigurationParser( final File xmlFile ) {
+ this.xmlFile = xmlFile;
+ }
+
/**
* Parses the configuration contained in xmlFile.
*/
- public IPackagerConfiguration parseConfiguration( final File xmlFile )
+ public IPackagerConfiguration parseConfiguration()
throws SAXException, IOException, ParserConfigurationException
{
return parseConfiguration( new XMLDocument( xmlFile ).getRootElement() );
@@ -74,6 +80,16 @@ public class ConfigurationParser {
return parseConfiguration( new XMLDocument( xml ).getRootElement() );
}
+ private IXmlElement[] getElements( final IXmlElement element,
+ final String name )
+ {
+ return element.getElements( name );
+ }
+
+ private String getFolderName( final IXmlElement element ) {
+ return element.getAttributeValue( ATTRIB_FOLDER );
+ }
+
/**
* Reads the various elements of the configuration from the root element.
*
@@ -88,33 +104,27 @@ public class ConfigurationParser {
parseUpdateSites( configuration, root );
parseRequiredFeatures( configuration, root );
parsePackagerConfigurationFolder( configuration, root );
- parseInstallerConfigurationFolder( configuration, root );
parseRootFolder( configuration, root );
parseExtensionSite( configuration, root );
parsePlatforms( configuration, root );
return configuration;
}
- private void parseRcp( final PackagerConfiguration configuration,
- final IXmlElement parent )
+ /** Loads and sets the extension site to use. */
+ private void parseExtensionSite( final PackagerConfiguration configuration,
+ final IXmlElement parent )
{
- String rcpVersion = parent.getElement( TAG_RCP )
- .getAttributeValue( ATTRIB_VERSION );
- configuration.setRcpVersion( rcpVersion );
+ IXmlElement element = parent.getElement( TAG_EXTENSION_SITE );
+ configuration.setExtensionSiteRelative( element.getAttributeValue( ATTRIB_RELATIVE_FOLDER ) );
}
- private void parseProduct( final PackagerConfiguration configuration,
- final IXmlElement parent )
+ /** Loads and sets the packager configuration folder to use. */
+ private void parsePackagerConfigurationFolder( final PackagerConfiguration configuration,
+ final IXmlElement parent )
{
- IXmlElement productElement = parent.getElement( TAG_PRODUCT );
- String productName = productElement.getAttributeValue( ATTRIB_NAME );
- configuration.setProductName( productName );
- String configIni = productElement.getAttributeValue( ATTRIB_CONFIG_INI );
- configuration.setConfigIni( configIni );
- String eclipseProductId = productElement.getAttributeValue( ATTRIB_ECLIPSE_PRODUCT_ID );
- configuration.setEclipseProductId( eclipseProductId );
- String initialPerspectiveId = productElement.getAttributeValue( ATTRIB_INITIAL_PERSPECTIVE_ID );
- configuration.setInitialPerspectiveId( initialPerspectiveId );
+ IXmlElement element = parent.getElement( TAG_PACKAGER_CONFIGURATION_FOLDER );
+ String folder = resolveRelativeFileName( getFolderName( element ) );
+ configuration.setPackagerConfigurationFolder( folder );
}
/** Loads and sets the target platforms. */
@@ -137,6 +147,26 @@ public class ConfigurationParser {
}
}
+ private void parseProduct( final PackagerConfiguration configuration,
+ final IXmlElement parent )
+ {
+ IXmlElement productElement = parent.getElement( TAG_PRODUCT );
+ String productName = productElement.getAttributeValue( ATTRIB_NAME );
+ configuration.setProductName( productName );
+ String eclipseProductId = productElement.getAttributeValue( ATTRIB_ECLIPSE_PRODUCT_ID );
+ configuration.setEclipseProductId( eclipseProductId );
+ String initialPerspectiveId = productElement.getAttributeValue( ATTRIB_INITIAL_PERSPECTIVE_ID );
+ configuration.setInitialPerspectiveId( initialPerspectiveId );
+ }
+
+ private void parseRcp( final PackagerConfiguration configuration,
+ final IXmlElement parent )
+ {
+ IXmlElement rcpElement = parent.getElement( TAG_RCP );
+ String rcpVersion = rcpElement.getAttributeValue( ATTRIB_VERSION );
+ configuration.setRcpVersion( rcpVersion );
+ }
+
/** Loads and sets the required features. */
private void parseRequiredFeatures( final PackagerConfiguration configuration,
final IXmlElement parent )
@@ -148,6 +178,15 @@ public class ConfigurationParser {
}
}
+ /** Loads and sets the folder containing the root files. */
+ private void parseRootFolder( final PackagerConfiguration configuration,
+ final IXmlElement parent )
+ {
+ IXmlElement element = parent.getElement( TAG_ROOT_FILE_FOLDER );
+ String folder = resolveRelativeFileName( getFolderName( element ) );
+ configuration.setRootFileFolder( folder );
+ }
+
/**
* Loads and sets the available update sites.
*
@@ -162,46 +201,16 @@ public class ConfigurationParser {
configuration.addUpdateSite( siteElement.getAttributeValue( ATTRIB_URL ) );
}
}
-
- /** Loads and sets the extension site to use. */
- private void parseExtensionSite( final PackagerConfiguration configuration,
- final IXmlElement parent )
- {
- IXmlElement element = parent.getElement( TAG_EXTENSION_SITE );
- configuration.setExtensionSiteRelative( element.getAttributeValue( ATTRIB_RELATIVE_FOLDER ) );
- }
-
- /** Loads and sets the packager configuration folder to use. */
- private void parsePackagerConfigurationFolder( final PackagerConfiguration configuration,
- final IXmlElement parent )
- {
- IXmlElement element = parent.getElement( TAG_PACKAGER_CONFIGURATION_FOLDER );
- configuration.setPackagerConfigurationFolder( getFolderName( element ) );
- }
-
- /** Loads and sets the installer configuration folder to use. */
- private void parseInstallerConfigurationFolder( final PackagerConfiguration configuration,
- final IXmlElement parent )
- {
- IXmlElement element = parent.getElement( TAG_INSTALLER_CONFIGURATION_FOLDER );
- configuration.setInstallerConfigurationFolder( getFolderName( element ) );
- }
-
- /** Loads and sets the folder containing the root files. */
- private void parseRootFolder( final PackagerConfiguration configuration,
- final IXmlElement parent )
- {
- IXmlElement element = parent.getElement( TAG_ROOT_FILE_FOLDER );
- configuration.setRootFileFolder( getFolderName( element ) );
- }
-
- private String getFolderName( final IXmlElement element ) {
- return element.getAttributeValue( ATTRIB_FOLDER );
- }
-
- private IXmlElement[] getElements( final IXmlElement element,
- final String name )
- {
- return element.getElements( name );
+
+ /*
+ * This method resolves a potentially relative file name. If the path is
+ * specified relative, then it is considered relative to the parent of the
+ * configuration (XML) file.
+ */
+ private String resolveRelativeFileName( final String path ) {
+ if( new File( path ).isAbsolute() )
+ return path;
+ return new File( this.xmlFile.getParent(), path ).toString();
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/IXmlElement.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/IXmlElement.java
index f8b234c9..f5981b00 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/IXmlElement.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/IXmlElement.java
@@ -16,19 +16,33 @@ public interface IXmlElement {
/**
* Returns all descendant elements of this element whose name equals the given
* name.
+ *
+ * @param tagName name of the tag
+ * @return element
*/
public IXmlElement[] getElements( String tagName );
/**
+ * Returns the first descendant element of the given name or <code>null</code>,
+ * if none exist.
+ *
+ * @param tagName name of the tag
+ * @return the element or <code>null</code>
+ */
+ public IXmlElement getElement( String tagName );
+
+ /**
* Returns the value of the given attribute.
+ *
+ * @param attributeName name of the XML attribute
+ * @return plain string value of the XML attribute
*/
public String getAttributeValue( String attributeName );
/**
- * Returns the first descendant element of the given name or <code>null</code>,
- * if none exist.
+ * Returns the text value of this element without any preprocessing.
+ *
+ * @return text of this XML element
*/
- public IXmlElement getElement( String tagName );
-
public String getText();
}
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XMLDocument.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XMLDocument.java
index 974f9fee..6268629c 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XMLDocument.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XMLDocument.java
@@ -14,6 +14,7 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -21,30 +22,55 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-/** An XML document based on W3C DOM */
+/**
+ * An XML document based on W3C DOM with a description of the EPP package.
+ */
public class XMLDocument {
private final Document document;
+ /**
+ * Creates a new instance of the XMLDocument from an input file.
+ *
+ * @param xmlFile the EPP configuration file
+ * @throws SAXException if the file cannot be parsed
+ * @throws IOException if the file cannot be read or parsed
+ * @throws ParserConfigurationException if the document builder cannot be
+ * created
+ */
public XMLDocument( final File xmlFile )
throws SAXException, IOException, ParserConfigurationException
{
- this.document = DocumentBuilderFactory.newInstance()
- .newDocumentBuilder()
- .parse( xmlFile );
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = docBuilderFactory.newDocumentBuilder();
+ this.document = documentBuilder.parse( xmlFile );
}
- /** @param A string with XML data */
+ /**
+ * Creates a new instance of the XMLDocument from an XML input string.
+ *
+ * @param xmlString the string containing the EPP configuration
+ * @throws SAXException if the file cannot be parsed
+ * @throws IOException if the file cannot be read or parsed
+ * @throws ParserConfigurationException if the document builder cannot be
+ * created
+ */
public XMLDocument( final String xmlString )
throws SAXException, IOException, ParserConfigurationException
{
- this.document = DocumentBuilderFactory.newInstance()
- .newDocumentBuilder()
- .parse( new ByteArrayInputStream( xmlString.getBytes() ) );
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = docBuilderFactory.newDocumentBuilder();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream( xmlString.getBytes() );
+ this.document = documentBuilder.parse( inputStream );
}
- /** Returns the root element of this document. */
+ /**
+ * Returns the root element (<code>configuration</code> element) of the EPP
+ * XML configuration.
+ *
+ * @return the root element of this document
+ */
public IXmlElement getRootElement() {
- return new XmlElement( ( Element )document.getFirstChild() );
+ return new XmlElement( ( Element )this.document.getFirstChild() );
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XmlElement.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XmlElement.java
index 477e2920..1c740c67 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XmlElement.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XmlElement.java
@@ -21,16 +21,17 @@ public class XmlElement implements IXmlElement {
private final Element node;
+ /**
+ * Creates a new XmlElement by providing a new node.
+ *
+ * @param node
+ */
public XmlElement( final Element node ) {
this.node = node;
}
- public String getAttributeValue( final String attributeName ) {
- return node.getAttribute( attributeName );
- }
-
public IXmlElement getElement( final String tagName ) {
- NodeList elementsByTagName = node.getElementsByTagName( tagName );
+ NodeList elementsByTagName = this.node.getElementsByTagName( tagName );
IXmlElement result;
if( elementsByTagName.getLength() == 0 ) {
result = null;
@@ -41,7 +42,7 @@ public class XmlElement implements IXmlElement {
}
public IXmlElement[] getElements( final String tagName ) {
- NodeList elementsByTagName = node.getElementsByTagName( tagName );
+ NodeList elementsByTagName = this.node.getElementsByTagName( tagName );
List<IXmlElement> result = new ArrayList<IXmlElement>();
for( int index = 0; index < elementsByTagName.getLength(); index++ ) {
result.add( new XmlElement( ( Element )elementsByTagName.item( index ) ) );
@@ -49,6 +50,10 @@ public class XmlElement implements IXmlElement {
return result.toArray( new IXmlElement[ result.size() ] );
}
+ public String getAttributeValue( final String attributeName ) {
+ return this.node.getAttribute( attributeName );
+ }
+
public String getText() {
return this.node.getTextContent();
}
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/messages.properties b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/messages.properties
index 984fe43b..505482f6 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/messages.properties
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/messages.properties
@@ -11,7 +11,6 @@ Application.Building=Building configured application
Application.Packing=Packing installation site.
EclipsePackager.ConfigurationFolder=Configuration files taken from {0}.
EclipsePackager.TargetFolder=The application will be built in {0}.
-EclipsePackager.InjectIni=Injecting config.ini from {0}.
EclipsePackager.Running=Building
PackageMover.MovingFiles=Moving Files
Logger.Done=Done. \ No newline at end of file

Back to the top