diff options
Diffstat (limited to 'plugins/org.eclipse.epp.packaging.core/src')
41 files changed, 0 insertions, 3080 deletions
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Activator.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Activator.java deleted file mode 100644 index a8e554fb..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/Activator.java +++ /dev/null @@ -1,60 +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; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends Plugin { - - /** The plug-in ID */ - public static final String PLUGIN_ID = "org.eclipse.epp.packaging.core"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - // do nothing - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) - */ - public void start( final BundleContext context ) throws Exception { - super.start( context ); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop( final BundleContext context ) throws Exception { - plugin = null; - super.stop( context ); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } -}
\ No newline at end of file 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 deleted file mode 100644 index aad9c642..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/EclipsePackagingExecutor.java +++ /dev/null @@ -1,94 +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; - -import java.io.IOException; -import java.net.URISyntaxException; - -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.PackageMover; -import org.eclipse.epp.packaging.core.configuration.ICommands; -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.Task; -import org.eclipse.epp.packaging.core.download.ExtensionSiteManager; -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/platform runnable - */ -public class EclipsePackagingExecutor { - - private final ICommands commands; - private final IPackagerConfiguration configuration; - - public EclipsePackagingExecutor( final ICommands commands, - final IPackagerConfiguration configuration ) - { - this.commands = commands; - this.configuration = configuration; - } - - /** - * Run the packaging process - * @throws URISyntaxException - */ - public void execute() throws CoreException, IOException, URISyntaxException { - 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( this.configuration ); - boolean areFeaturesPresent - = manager.areFeaturesPresent( this.configuration.getRequiredFeatures() ); - if( areFeaturesPresent ) { - if( this.commands.mustDo( Task.INSTALL ) ) { - install( manager ); - } - build(); - } - } else { - build(); - } - } - - private void build() throws IOException, CoreException, URISyntaxException { - 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(); - MessageLogger.getInstance().logEndProcess(); - } - } - - /** - * Installs all requested features from the update sites to an extension - * location. - */ - private void install( final IUpdateSiteManager manager ) - throws IOException, CoreException - { - MessageLogger.getInstance().logBeginProcess( "Application.Installing" ); //$NON-NLS-1$ - 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/PackagingApplication.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/PackagingApplication.java deleted file mode 100644 index 69320ace..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/PackagingApplication.java +++ /dev/null @@ -1,58 +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; - -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.epp.packaging.core.configuration.ArgumentParser; -import org.eclipse.epp.packaging.core.configuration.ICommands; -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.xml.ConfigurationParser; -import org.eclipse.equinox.app.IApplication; -import org.eclipse.equinox.app.IApplicationContext; - -/** - * Main entry point for the EPP packager. - */ -public class PackagingApplication implements IApplication { - - public Object start( final IApplicationContext context ) throws Exception { - Map<?, ?> arguments = context.getArguments(); - String[] args = ( String[] )arguments.get( IApplicationContext.APPLICATION_ARGS ); - ICommands commands = ArgumentParser.parse( args ); - ConfigurationParser configurationParser - = new ConfigurationParser( commands.getConfigurationFile() ); - IPackagerConfiguration configuration - = configurationParser.parseConfiguration(); - IStatus checkFeaturesResult - = configuration.checkFeatures( new NullProgressMonitor() ); - - IStatus[] status = checkFeaturesResult.getChildren(); - for( IStatus singleStatus : status ) { - System.out.println( singleStatus.getMessage() ); - } - - if( checkFeaturesResult.getSeverity() == IStatus.OK - || checkFeaturesResult.getSeverity() == IStatus.INFO - || checkFeaturesResult.getSeverity() == IStatus.WARNING ) { - EclipsePackagingExecutor packagingExecutor - = new EclipsePackagingExecutor( commands, configuration ); - packagingExecutor.execute(); - } - return EXIT_OK; - } - - public void stop() { - // nothing to stop here... - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/CustomTargetsWriter.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/CustomTargetsWriter.java deleted file mode 100644 index 3ea9b0db..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/CustomTargetsWriter.java +++ /dev/null @@ -1,116 +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.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.net.URISyntaxException; -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.epp.packaging.core.Activator; -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.IPlatform; -import org.eclipse.epp.packaging.core.io.FileUtils; -import org.osgi.framework.Bundle; - -/** - * Completes the custom targets stub to form a customtargets.xml ant file. - * The targets added define the output files for each platform. - */ -public class CustomTargetsWriter { - - private static final String SKELETONS_DIRECTORY = "skeletons/"; //$NON-NLS-1$ - private final PrintWriter writer; - private final IPackagerConfiguration configuration; - - /** - * TODO mknauer missing doc - * @param configuration - * @param baseFile - * @throws IOException - * @throws URISyntaxException - */ - public CustomTargetsWriter( final IPackagerConfiguration configuration, - final String baseFile ) - throws IOException, URISyntaxException - { - this.configuration = configuration; - - IPath path = new Path( SKELETONS_DIRECTORY + baseFile ); - Bundle bundle = Activator.getDefault().getBundle(); - URL url = FileLocator.find( bundle, path, null ); - URL fileURL = FileLocator.toFileURL( url ); - File stubFile = new File( fileURL.toURI() ); - - File customTargetsFile = new File( configuration.getPackagerConfigurationFolder(), - "customTargets.xml" ); //$NON-NLS-1$ - FileUtils.copy( stubFile, customTargetsFile ); - FileOutputStream stream = new FileOutputStream( customTargetsFile, true ); - this.writer = new PrintWriter( stream ); - } - - /** - * TODO mknauer missing doc - * @param platform - */ - public void addTargetFileForPlatform( final IPlatform platform ) { - this.writer.append( " <target name=\"assemble." //$NON-NLS-1$ - + platform.toString( '.' ) - + ".xml\" depends=\"init\">\n" ); //$NON-NLS-1$ - - this.writer.append( " <replaceregexp file=\"${tempDirectory}/" //$NON-NLS-1$ - + platform.toString( '.' ) - + "/eclipse/configuration/config.ini\"\n" ); //$NON-NLS-1$ - this.writer.append( " match=\"eclipse.product=(.*)\"\n" ); //$NON-NLS-1$ - this.writer.append( " replace=\"eclipse.product=" //$NON-NLS-1$ - + this.configuration.getEclipseProductId() - + "\"\n" ); //$NON-NLS-1$ - this.writer.append( " byline=\"true\" />\n" ); //$NON-NLS-1$ - - this.writer.append( " <replaceregexp byline=\"true\">\n" ); //$NON-NLS-1$ - this.writer.append( " <regexp pattern=\"org.eclipse.ui/defaultPerspectiveId=(.*)\"/>\n" ); //$NON-NLS-1$ - this.writer.append( " <substitution expression=\"org.eclipse.ui/defaultPerspectiveId=" //$NON-NLS-1$ - + this.configuration.getInitialPerspectiveId() - + "\"/>\n" ); //$NON-NLS-1$ - this.writer.append( " <fileset dir=\"${tempDirectory}/eclipse/plugins/\" includes=\"" //$NON-NLS-1$ -// + this.configuration.getEclipseProductId() - + "*/plugin_customization.ini\"/>\n" ); //$NON-NLS-1$ - this.writer.append( " </replaceregexp>\n" ); //$NON-NLS-1$ - - this.writer.append( " <echo file=\"${tempDirectory}/" //$NON-NLS-1$ - + platform.toString( '.' ) - + platform.getEclipseIniFilePath() - + "eclipse.ini\">" ); //$NON-NLS-1$ - this.writer.append( platform.getEclipseIniFileContent() ); - this.writer.append( " </echo>\n" ); //$NON-NLS-1$ - - this.writer.append( " <ant antfile=\"${assembleScriptName}\" >\n" ); //$NON-NLS-1$ - this.writer.append( " <property name=\"archiveName\" value=\"" //$NON-NLS-1$ - + platform.getTargetFileName( this.configuration ) - + platform.getArchiveFormat().getExtension() - + "\"/>\n" ); //$NON-NLS-1$ - this.writer.append( " </ant>\n" ); //$NON-NLS-1$ - this.writer.append( " </target>\n" ); //$NON-NLS-1$ - } - - /** - * TODO mknauer missing doc - */ - public void close() { - this.writer.append( "</project>\n" ); //$NON-NLS-1$ - this.writer.close(); - } -} 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 deleted file mode 100644 index 3045076a..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/EclipsePackager.java +++ /dev/null @@ -1,164 +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.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.epp.packaging.core.Activator; -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.IPlatform; -import org.eclipse.epp.packaging.core.io.FileUtils; -import org.eclipse.epp.packaging.core.io.Zip; -import org.eclipse.epp.packaging.core.logging.MessageLogger; -import org.eclipse.update.core.VersionedIdentifier; -import org.osgi.framework.Bundle; - -/** - * An IPackager using the main configuration as its argument. - */ -public class EclipsePackager implements IPackager { - - private static final String PACKAGER_SKELETON_DIR - = "skeletons/"; //$NON-NLS-1$ - private static final String PACKAGER_PROPERTIES_FILE - = "packager.properties"; //$NON-NLS-1$ - private static final String CONFIGURED_FEATURES_ZIP - = "ConfiguredFeatures.zip"; //$NON-NLS-1$ - private final PackagerRunner runner; - - /** - * TODO mknauer missing doc - * @param configuration - * @throws IOException - * @throws URISyntaxException - */ - public EclipsePackager( final IPackagerConfiguration configuration ) - throws IOException, URISyntaxException - { - this.runner = new PackagerRunner(); - setFolders( configuration ); - setFeatures( configuration ); - configurePlatforms( configuration ); - prepareWorkingArea( configuration ); - } - - /** - * Creates the map file in the workspace and clears the existing work area. - * - * @throws URISyntaxException - */ - private void prepareWorkingArea( final IPackagerConfiguration configuration ) - throws IOException, URISyntaxException - { - FileUtils.deleteFile( new File( configuration.getTargetFolder(), - "workingPlace" ) ); //$NON-NLS-1$ - MapFileWriter mapWriter = new MapFileWriter( configuration ); - PackagingPropertiesWriter propertiesWriter - = new PackagingPropertiesWriter( configuration, "packagingStub.properties" ); //$NON-NLS-1$ - CustomTargetsWriter customTargetsWriter - = new CustomTargetsWriter( configuration, "customTargetsStub.xml" ); //$NON-NLS-1$ - - for( IPlatform platform : configuration.getTargetPlatforms() ) { - mapWriter.addRootFileForPlatform( platform ); - propertiesWriter.addFileToOrder( platform.getRootFileName( configuration ) ); - customTargetsWriter.addTargetFileForPlatform( platform ); - } - - File sourceFolder = new File( configuration.getTargetFolder(), "src" ); //$NON-NLS-1$ - sourceFolder.mkdir(); - zipFeatures( sourceFolder, configuration ); - writeDataForCustomFile( CONFIGURED_FEATURES_ZIP, - mapWriter, - propertiesWriter ); - mapWriter.close(); - propertiesWriter.close(); - customTargetsWriter.close(); - - IPath path = new Path( PACKAGER_SKELETON_DIR + PACKAGER_PROPERTIES_FILE ); - Bundle bundle = Activator.getDefault().getBundle(); - URL url = FileLocator.find( bundle, path, null ); - URL fileURL = FileLocator.toFileURL( url ); - File packagerPropertiesFile = new File( fileURL.toURI() ); - File destinationPPFile = new File( configuration.getPackagerConfigurationFolder(), - PACKAGER_PROPERTIES_FILE ); - FileUtils.copy( packagerPropertiesFile, destinationPPFile ); - } - - private void writeDataForCustomFile( final String filename, - final MapFileWriter mapWriter, - final PackagingPropertiesWriter propertiesWriter ) - { - mapWriter.addCustomFileForAllPlatforms( filename ); - propertiesWriter.addFileToOrder( filename ); - } - - /** - * Zips the requested features from the extension location into a single file. - */ - private void zipFeatures( final File parentFolder, - final IPackagerConfiguration configuration ) - throws IOException - { - MessageLogger.getInstance().logBeginProcess( "Application.Packing" ); //$NON-NLS-1$ - Zip zip = new Zip( parentFolder, CONFIGURED_FEATURES_ZIP ); - zip.addFolder( configuration.getExtensionSite() ); - zip.close(); - MessageLogger.getInstance().logEndProcess(); - } - - /** Sets the required folder info. */ - private void setFolders( final IPackagerConfiguration configuration ) - throws IOException - { - String packagerConfiguration - = configuration.getPackagerConfigurationFolder().getCanonicalPath(); - MessageLogger logger = MessageLogger.getInstance(); - - logger.log( "EclipsePackager.ConfigurationFolder", packagerConfiguration ); //$NON-NLS-1$ - this.runner.setConfigurationFolder( packagerConfiguration ); - - String targetFolder = configuration.getTargetFolder().getCanonicalPath(); - logger.log( "EclipsePackager.TargetFolder", targetFolder ); //$NON-NLS-1$ - this.runner.setBaseDirectory( targetFolder ); - } - - /** Sets the features to be included. */ - private void setFeatures( final IPackagerConfiguration configuration ) { - for( VersionedIdentifier identifier : configuration.getRequiredFeatures() ) - { - this.runner.addFeature( identifier.getIdentifier() ); - } - } - - /** Configures the runner with platform information from configuration. */ - private void configurePlatforms( final IPackagerConfiguration configuration ) - { - for( IPlatform platform : configuration.getTargetPlatforms() ) { - String platformString = platform.toString(); - this.runner.addPlatform( platformString ); - String archiveFormatName = platform.getArchiveFormat().name(); - this.runner.setArchiveFormat( platformString, archiveFormatName ); - } - } - - public void packApplication() throws CoreException, IOException { - MessageLogger.getInstance().logBeginProcess( "EclipsePackager.Running" ); //$NON-NLS-1$ - this.runner.packApplication(); - MessageLogger.getInstance().logEndProcess(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/IPackager.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/IPackager.java deleted file mode 100644 index 8a982d62..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/IPackager.java +++ /dev/null @@ -1,29 +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.core.runtime.CoreException; - -/** - * Implementors know how to package an RCP Application. - */ -public interface IPackager { - - /** - * Begins the packing process. - * TODO mknauer missing doc - * @throws CoreException - * @throws IOException - */ - public void packApplication() throws CoreException, IOException; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/MapFileWriter.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/MapFileWriter.java deleted file mode 100644 index fa7f5022..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/MapFileWriter.java +++ /dev/null @@ -1,95 +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.File; -import java.io.IOException; -import java.io.PrintWriter; - -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.IPlatform; - -/** - * Creates a packager map file in the workspace. - */ -public class MapFileWriter { - - private final static String MAP_FILE_LINE_END = " | | sdk | eclipse\n"; //$NON-NLS-1$ - private final IPackagerConfiguration configuration; - private final PrintWriter writer; - - /** - * TODO mknauer missing doc - * @param configuration - * @throws IOException - */ - public MapFileWriter( final IPackagerConfiguration configuration ) - throws IOException - { - this.configuration = configuration; - File parent = new File( configuration.getTargetFolder(), "toPackage" ); //$NON-NLS-1$ - parent.mkdir(); - this.writer = new PrintWriter( new File( parent, "PackagerMap.map" ) ); //$NON-NLS-1$ - } - - /** - * TODO mknauer missing doc - * @param platform - */ - public void addRootFileForPlatform( final IPlatform platform ) { - String rootFileFolder = this.configuration.getRootFileFolder().toURI().toString(); - String rootFileName = platform.getRootFileName( this.configuration ); - this.writer.append( rootFileName + "=" //$NON-NLS-1$ - + rootFileFolder - + " | " //$NON-NLS-1$ - + platform.toString() - + MAP_FILE_LINE_END ); - } - - /** - * Adds the given file name to the map. The file is expected to reside in the - * 'src' folder in the workspace. It is designated as valid for all configured - * platforms. - * - * TODO mknauer missing doc - * - * @param filename - */ - public void addCustomFileForAllPlatforms( final String filename ) { - File targetFolder = this.configuration.getTargetFolder(); - String sourceFolder = new File( targetFolder, "src" ).toURI().toString(); //$NON-NLS-1$ - this.writer.append( filename - + "=" //$NON-NLS-1$ - + sourceFolder - + " | " //$NON-NLS-1$ - + getAllPlatformsString() - + MAP_FILE_LINE_END ); - } - - /** - * TODO mknauer missing doc - */ - public void close() { - this.writer.close(); - } - - private String getAllPlatformsString() { - StringBuilder builder = new StringBuilder(); - IPlatform[] platforms = this.configuration.getTargetPlatforms(); - for( int index = 0; index < platforms.length; index++ ) { - builder.append( platforms[ index ].toString() ); - if( index < platforms.length - 1 ) { - builder.append( '&' ); - } - } - return builder.toString(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackageMover.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackageMover.java deleted file mode 100644 index f6678517..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackageMover.java +++ /dev/null @@ -1,77 +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.File; -import java.io.FileFilter; -import java.io.IOException; - -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.IPlatform; -import org.eclipse.epp.packaging.core.io.FileUtils; -import org.eclipse.epp.packaging.core.logging.MessageLogger; - -/** - * Moves the created packages from the packager's work directory to the main - * folder specified in the configuration. - */ -public class PackageMover { - - private final IPackagerConfiguration configuration; - - /** - * TODO mknauer missing doc - * @param configuration - */ - public PackageMover( final IPackagerConfiguration configuration ) { - this.configuration = configuration; - } - - /** - * TODO mknauer missing doc - * Moves the created packages to their final location. - * @throws IOException - */ - public void moveFiles() throws IOException { - MessageLogger.getInstance().logBeginProcess( "PackageMover.MovingFiles" ); //$NON-NLS-1$ - File packageLocation = new File( this.configuration.getTargetFolder(), - "workingPlace/I.EclipsePackagerBuild" ); //$NON-NLS-1$ - for( IPlatform platform : this.configuration.getTargetPlatforms() ) { - File applicationFile = findPlatformFile( packageLocation, platform ); - FileUtils.copy( applicationFile, - new File( this.configuration.getTargetFolder(), - applicationFile.getName() ) ); - } - MessageLogger.getInstance().logEndProcess(); - } - - /** Returns the created package for the given platform. */ - private File findPlatformFile( final File packageLocation, - final IPlatform platform ) - { - final String name = platform.getTargetFileName( this.configuration ) - + platform.getArchiveFormat().getExtension(); - File[] files = packageLocation.listFiles( new FileFilter() { - - public boolean accept( final File file ) { - return file.getName().equals( name ); - } - } ); - if( files.length != 1 ) { - throw new IllegalStateException( files.length - + " packages found for " //$NON-NLS-1$ - + platform - + ". There should be one, and only one." //$NON-NLS-1$ - ); - } - return files[ 0 ]; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackagerRunner.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackagerRunner.java deleted file mode 100644 index 8976e658..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackagerRunner.java +++ /dev/null @@ -1,136 +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 java.util.ArrayList; -import java.util.List; - -import org.eclipse.ant.core.AntRunner; -import org.eclipse.core.runtime.CoreException; - -/** - * An IPackager based on the PDE Build packager. Locates, configures and - * executes the package.xml ant script - */ -public class PackagerRunner implements IPackager { - - private static final String ARGUMENT_ARCHIVE_FORMATS = "archivesFormat"; //$NON-NLS-1$ - private static final String ARGUMENT_BASE_DIRECTORY = "baseDirectory";//$NON-NLS-1$ - private static final String ARGUMENT_CONFIGURATION_FOLDER = "packagingInfo";//$NON-NLS-1$ - private static final String ARGUMENT_FEATURE_LIST = "featureList";//$NON-NLS-1$ - private static final String ARGUMENT_PLATFORM_LIST = "config";//$NON-NLS-1$ - private static final String PDE_BUILD_PLUGIN_ID = "org.eclipse.pde.build";//$NON-NLS-1$ - private final List<String> features = new ArrayList<String>(); - private final List<String> platforms = new ArrayList<String>(); - private final List<String> formats = new ArrayList<String>(); - - public void packApplication() throws CoreException, IOException { - AntRunner runner = new AntRunner(); - String scriptLocation = PluginUtils.getPluginPath( PDE_BUILD_PLUGIN_ID ) - + "/scripts/package.xml";//$NON-NLS-1$ - runner.setBuildFileLocation( scriptLocation ); - addFeatureListToArguments(); - addPlatformListToArguments(); - addFormatListToArguments(); - runner.run(); - } - - /** - * Prior to running the packager, convert the list of archive formats to an - * argument string and add it to the list of arguments. - */ - private void addFormatListToArguments() { - addListToArguments( this.formats, '&', ARGUMENT_ARCHIVE_FORMATS ); - } - - /** - * Prior to running the packager, convert the list of platforms to an argument - * string and add it to the list of arguments. - */ - private void addPlatformListToArguments() { - addListToArguments( this.platforms, '&', ARGUMENT_PLATFORM_LIST ); - } - - /** - * Prior to running the packager, convert the list of features to an argument - * string and add it to the list of arguments. - */ - private void addFeatureListToArguments() { - addListToArguments( this.features, ',', ARGUMENT_FEATURE_LIST ); - } - - /** - * Converts the source list to a string with the entries separated by - * separator, then sets the result as a value for the argument. - */ - private void addListToArguments( final List<String> sourceList, - final char separator, - final String argumentName ) - { - StringBuilder builder = new StringBuilder(); - for( String feature : sourceList ) { - builder.append( feature ); - builder.append( separator ); - } - setArgument( argumentName, builder.toString() ); - } - - /** - * Sets the configuration folder for the PDE packager. The folder must contain - * packager.properties, packaging.properties and customTargets.xml. - * - * @param folder directory name - */ - public void setConfigurationFolder( final String folder ) { - setArgument( ARGUMENT_CONFIGURATION_FOLDER, folder ); - } - - /** Sets the working directory for the PDE packager. - * @param folder directory name of the base directory - */ - public void setBaseDirectory( final String folder ) { - setArgument( ARGUMENT_BASE_DIRECTORY, folder ); - } - - /** - * Adds a feature to the configured application. - * - * @param identifier The feature id. - */ - public void addFeature( final String identifier ) { - this.features.add( identifier ); - } - - /** Sets an argument for the AntRunner to use. */ - private void setArgument( final String key, final String value ) { - System.setProperty( key, value ); - } - - /** - * Adds a new target platform to the configuration. - * - * @param platform A comma-separated platform description (os,ws,arch). - */ - public void addPlatform( final String platform ) { - this.platforms.add( platform ); - } - - /** - * Sets a platform's archive format. - * - * @param platform A comma-separated platform description - os,ws,arch. - * @param format An archive format. Supported values are antZip, antTar, tar. - */ - public void setArchiveFormat( final String platform, final String format ) { - this.formats.add( platform + '-' + format ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackagingPropertiesWriter.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackagingPropertiesWriter.java deleted file mode 100644 index 4cbb6fe2..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PackagingPropertiesWriter.java +++ /dev/null @@ -1,80 +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.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.net.URISyntaxException; -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.epp.packaging.core.Activator; -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.io.FileUtils; -import org.osgi.framework.Bundle; - -/** - * Completes the packaging.properties file by adding the unzipOrder property. - */ -public class PackagingPropertiesWriter { - - private static final String SKELETONS_PACKAGING_PROPERTIES = "skeletons/packagingStub.properties"; //$NON-NLS-1$ - private static final String UNZIP_ORDER_PROPERTY = "unzipOrder"; //$NON-NLS-1$ - private static final String PACKAGING_PROPERTIES_FILENAME = "packaging.properties"; //$NON-NLS-1$ - private final PrintWriter writer; - private boolean firstName = true; - - /** - * @param configuration - * @param baseFile - * @throws IOException - * @throws URISyntaxException - */ - public PackagingPropertiesWriter( final IPackagerConfiguration configuration, - final String baseFile ) - throws IOException, URISyntaxException - { - IPath path = new Path( SKELETONS_PACKAGING_PROPERTIES ); - Bundle bundle = Activator.getDefault().getBundle(); - URL url = FileLocator.find( bundle, path, null ); - URL fileURL = FileLocator.toFileURL( url ); - File stubFile = new File( fileURL.toURI() ); - - File packagingFile = new File( configuration.getPackagerConfigurationFolder(), - PACKAGING_PROPERTIES_FILENAME ); - FileUtils.copy( stubFile, packagingFile ); - FileOutputStream stream = new FileOutputStream( packagingFile, true ); - this.writer = new PrintWriter( stream ); - this.writer.append( UNZIP_ORDER_PROPERTY + '=' ); - } - - /** - * @param fileName - */ - public void addFileToOrder( final String fileName ) { - if( !this.firstName ) { - this.writer.append( ',' ); - } else { - this.firstName = false; - } - this.writer.append( fileName ); - } - - /** - */ - public void close() { - this.writer.close(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PluginUtils.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PluginUtils.java deleted file mode 100644 index 39448ace..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/assembly/PluginUtils.java +++ /dev/null @@ -1,52 +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.File; -import java.io.IOException; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.osgi.service.datalocation.Location; - -/** - * Utility class for Plugin-related tasks. - */ -public class PluginUtils { - - /** Locates the given plugin in the install location. - * - * TODO mknauer missing doc - * @param pluginId - * @return plugin path - * @throws IOException - */ - // This could be done via SiteManager and featurereferences, if the - // application was feature-based, not plugin-based. - public static String getPluginPath( final String pluginId ) throws IOException { - Location installLocation = Platform.getInstallLocation(); - String locationFile = installLocation.getURL().getFile(); - File file = new File( locationFile, "plugins" ); //$NON-NLS-1$ - String result = null; - for( File pluginFile : file.listFiles() ) { - if( pluginFile.getName().startsWith( pluginId ) ) { - result = pluginFile.getCanonicalPath(); - } - } - if( result == null ) { - throw new IllegalStateException( "Required plug-in " //$NON-NLS-1$ - + pluginId - + " not found in folder " //$NON-NLS-1$ - + locationFile - + "plugins." ); //$NON-NLS-1$ - } - return result; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ArchiveFormat.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ArchiveFormat.java deleted file mode 100644 index 2bad3484..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ArchiveFormat.java +++ /dev/null @@ -1,46 +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.configuration; - -/** - * Enumerates the archive formats. "antTar" will not be available until - * http://issues.apache.org/bugzilla/show_bug.cgi?id=39617 and - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=142792 are fixed. - */ -public enum ArchiveFormat { - - /** - * Archive format with the file extension <tt>.tar.gz</tt>. - */ - tar { - - @Override - public String getExtension() { - return ".tar.gz"; //$NON-NLS-1$ - } - }, - - /** - * Archive format with the file extension <tt>.zip</tt>. - */ - antZip { - - @Override - public String getExtension() { - return ".zip"; //$NON-NLS-1$ - } - }; - - /** - * @return the file extension that matches the archive format. - */ - public abstract String getExtension(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ArgumentParser.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ArgumentParser.java deleted file mode 100644 index c3b26669..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ArgumentParser.java +++ /dev/null @@ -1,37 +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.configuration; - -/** - * Parses the arguments given to the main application. - */ -public class ArgumentParser { - - /** - * @param args the argument vector as a String array - * @return an initialised <code>ICommand</code> object with the parsed - * command line options - * @throws IllegalArgumentException if arguments is no array of strings. - */ - public static ICommands parse( final String[] args ) { - if( args == null || args.length == 0 ) { - throw new IllegalArgumentException( "Argument must contain at least one value." ); //$NON-NLS-1$ - } - Commands command = new Commands(); - command.setConfigurationFile( args[ 0 ] ); - if( args.length > 1 ) { - String[] tasks = new String[ args.length - 1 ]; - System.arraycopy( args, 1, tasks, 0, tasks.length ); - command.setTasks( tasks ); - } - return command; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Commands.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Commands.java deleted file mode 100644 index 58811396..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Commands.java +++ /dev/null @@ -1,48 +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.configuration; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * Configurable default implementation of ICommands. - */ -public class Commands implements ICommands { - - private File file; - private Task[] tasks = Task.values(); - - public File getConfigurationFile() { - return file; - } - - public void setConfigurationFile( final String fileName ) { - this.file = new File( fileName ); - } - - public boolean mustDo( final Task task ) { - boolean result = false; - for( Task configuredTask : tasks ) { - result |= configuredTask.equals( task ); - } - return result; - } - - public void setTasks( final String[] tasks ) { - List<Task> taskList = new ArrayList<Task>(); - for( String task : tasks ) { - taskList.add( Task.valueOf( task.toUpperCase() ) ); - } - this.tasks = taskList.toArray( new Task[ taskList.size() ] ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/FeatureVersionRepository.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/FeatureVersionRepository.java deleted file mode 100644 index 68b637b5..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/FeatureVersionRepository.java +++ /dev/null @@ -1,99 +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.configuration; - -import java.util.HashMap; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.eclipse.update.core.VersionedIdentifier; -import org.osgi.framework.Version; - - -/** - * - */ -public class FeatureVersionRepository { - - private Map<String, VersionList> features = new HashMap<String, VersionList>(); - - public void addVersionIdentifier( final VersionedIdentifier versionedIdentifier ) { - String identifier = versionedIdentifier.getIdentifier(); - String version = versionedIdentifier.getVersion().toString(); - - if( !this.features.containsKey( identifier ) ) { - this.features.put( identifier, new VersionList() ); - } - VersionList versionList = this.features.get( identifier ); - versionList.addVersion( version ); - } - - /** - * Searches for the highest version number of a given feature or bundle, - * identified by the identifier string. - * - * @param identifier of the feature - * @return the highest available version number or <code>null</code> if the - * identifier is not found. - */ - public Version getHighestVersion( final String identifier ) { - Version result = null; - VersionList versionList = this.features.get( identifier ); - if( versionList != null ) { - result = versionList.getHighestVersion(); - } - return result; - } - - /** - * Checks if a given identifier is already in the list of available features. - * - * @param identifier String with the feature identifier. - * @return <code>true</code> if the identifier is found in the list of - * available features, <code>false</code> otherwise. - */ - public boolean containsIdentifier( final String identifier ) { - return this.features.containsKey( identifier ); - } - - - /** - * This class provides a modifiable list of - * <code>PluginVersionIdentifier</code> and returns the highest possible - * version number. Internally it uses the OSGi <code>Version</code> - * implementation because of its <code>Comparable</code> interface. - */ - class VersionList { - - private SortedSet<Version> versions = new TreeSet<Version>(); - - /** - * Adds a new version to the list of available versions if the version is - * not yet included in the list. - * - * @param version the version that is to be added to the list - */ - void addVersion( final String versionString ) { - Version version = new Version( versionString ); - if( !this.versions.contains( version ) ) { - this.versions.add( version ); - } - } - - /** - * @return the highest version number in the list - */ - Version getHighestVersion() { - return this.versions.last(); - } - } -} diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ICommands.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ICommands.java deleted file mode 100644 index 4917c701..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/ICommands.java +++ /dev/null @@ -1,23 +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.configuration; - -import java.io.File; - -/** - * Object representation of arguments given to the program. - */ -public interface ICommands { - - public File getConfigurationFile(); - - public boolean mustDo( Task task ); -}
\ 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 deleted file mode 100644 index a158a1f8..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IModifiablePackagerConfiguration.java +++ /dev/null @@ -1,50 +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.configuration; - -import java.net.MalformedURLException; - -/** - * A packager configuration that allows to modify its settings. - */ -public interface IModifiablePackagerConfiguration - extends IPackagerConfiguration -{ - - /**Adds an update site to the configuration. - * - * @param string A string containing the URL of the site. - * @throws MalformedURLException if the URL is invalid. - */ - public void addUpdateSite( final String string ) throws MalformedURLException; - - /**Adds the feature [id] with the given version to the list of required features.*/ - public void addRequiredFeature( final String id, final String version ); - - /**Sets the extension site's name in the target folder.*/ - public void setExtensionSiteRelative( final String relativeFolder ); - - /**Adds a new target platform.*/ - public Platform addTargetPlatform( final String os, - final String ws, - final String arch, - final String eclipseIniFileContent, - final String eclipseIniFilePath ); - - /**Sets the RCP version to use.*/ - public void setRcpVersion( final String version ); - - /**Sets the folder containing the RCP root files.*/ - public void setRootFileFolder( final String folderName ); - - /**Sets the product name to use for the final result.*/ - public void setProductName( final String name ); -}
\ 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 deleted file mode 100644 index 387d5413..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPackagerConfiguration.java +++ /dev/null @@ -1,49 +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.configuration; - -import java.io.File; -import java.net.URL; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.update.core.VersionedIdentifier; - -/** - * Provides all data the Eclipse Packager requires to run. - */ -public interface IPackagerConfiguration { - - public URL[] getUpdateSites(); - - public VersionedIdentifier[] getRequiredFeatures(); - - public File getPackagerConfigurationFolder(); - - public File getTargetFolder(); - - public File getExtensionSite(); - - public IPlatform[] getTargetPlatforms(); - - public String getRootFileBaseName(); - - public File getRootFileFolder(); - - public String getProductName(); - - public String getEclipseProductId(); - - public String getInitialPerspectiveId(); - - public IStatus checkFeatures( IProgressMonitor monitor ) throws CoreException; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPlatform.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPlatform.java deleted file mode 100644 index a18977af..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/IPlatform.java +++ /dev/null @@ -1,54 +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.configuration; - -/** - * Represents a platform configuration, consisting of operating system (os), - * window system (ws) and system architecture (arch). - */ -public interface IPlatform { - - public ArchiveFormat getArchiveFormat(); - - /** - * Returns the platform components separated by the separator. Example: - * toString(".") for linux,gtk,x86 return "linux.gtk.x86". - * - * @param separator A separator character - * @return The platform description formatted as - * [OS][separator][WS][separator][Arch] - */ - public String toString( char separator ); - - /** - * Builds the file name of the platform files for this platform, using the - * base name provided in configuration. - */ - public String getRootFileName( IPackagerConfiguration configuration ); - - /** Configures the SiteManager to use platform as its current one. */ - public void configureSite(); - - /** - * Builds and returns the filename of the target archive for this platform, - * using the base name provided in configuration. - */ - public String getTargetFileName( IPackagerConfiguration configuration ); - - /** Returns the name installer-creating script most suitable for this platform. */ - public String getInstallScriptName(); - - /** Returns a string with the content of the eclipse.ini file */ - public String getEclipseIniFileContent(); - - /** Returns a string with the internal path to eclipse.ini */ - public String getEclipseIniFilePath(); -} 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 deleted file mode 100644 index 1ed36c6e..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java +++ /dev/null @@ -1,227 +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.configuration; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.epp.packaging.core.Activator; -import org.eclipse.update.core.ISite; -import org.eclipse.update.core.ISiteFeatureReference; -import org.eclipse.update.core.SiteManager; -import org.eclipse.update.core.VersionedIdentifier; -import org.osgi.framework.Version; - -/** - * A configurable IPackagerConfiguration. All data is handed in as String, then - * converted to the proper objects. - */ -public class PackagerConfiguration implements IModifiablePackagerConfiguration { - - private static final String PACKAGER_CONFIGURATION_DIRECTORY - = "packagerConfiguration"; //$NON-NLS-1$ - - private static final String ECLIPSE_PLATTFORM - = "eclipse-platform-"; //$NON-NLS-1$ - - private final List<URL> updateSites = new ArrayList<URL>(); - private final List<Platform> targetPlatforms = new ArrayList<Platform>(); - private List<VersionedIdentifier> requiredFeatures = new ArrayList<VersionedIdentifier>(); - private File baseFolder; - private File extensionSite; - private String rcpVersion; - private File rootFolder; - private String productName; - private String eclipseProductId; - private String initialPerspectiveId; - - public PackagerConfiguration() { - this.baseFolder = org.eclipse.core.runtime.Platform.getLocation().toFile(); - } - - public URL[] getUpdateSites() { - return this.updateSites.toArray( new URL[ this.updateSites.size() ] ); - } - - public void addUpdateSite( final String string ) throws MalformedURLException - { - this.updateSites.add( new URL( string ) ); - } - - public VersionedIdentifier[] getRequiredFeatures() { - return this.requiredFeatures.toArray( new VersionedIdentifier[ this.requiredFeatures.size() ] ); - } - - public void addRequiredFeature( final String id, final String version ) { - this.requiredFeatures.add( new VersionedIdentifier( id, version ) ); - } - - public File getTargetFolder() { - return this.baseFolder; - } - - public File getPackagerConfigurationFolder() { - File result = new File( this.baseFolder, PACKAGER_CONFIGURATION_DIRECTORY ); - if( ! result.isDirectory() ) { - result.mkdir(); - } - return result; - } - - public void setExtensionSiteRelative( final String relativeFolder ) { - this.extensionSite = new File( this.baseFolder, relativeFolder ); - } - - public File getExtensionSite() { - return this.extensionSite; - } - - public Platform addTargetPlatform( final String os, - final String ws, - final String arch, - final String eclipseIniFileContent, - final String eclipseIniFilePath ) - { - Platform platform = new Platform( os, ws, arch, eclipseIniFileContent, eclipseIniFilePath ); - this.targetPlatforms.add( platform ); - return platform; - } - - public IPlatform[] getTargetPlatforms() { - return this.targetPlatforms.toArray( new IPlatform[ this.targetPlatforms.size() ] ); - } - - public String getRootFileBaseName() { - return ECLIPSE_PLATTFORM + this.rcpVersion + '-'; - } - - public File getRootFileFolder() { - return this.rootFolder; - } - - public void setRcpVersion( final String version ) { - this.rcpVersion = version; - } - - public void setRootFileFolder( final String folderName ) { - this.rootFolder = new File( folderName ); - } - - public void setProductName( final String name ) { - this.productName = name; - } - - public String getProductName() { - return this.productName; - } - - public void setEclipseProductId( final String eclipseProductId ) { - this.eclipseProductId = eclipseProductId; - } - - public String getEclipseProductId() { - return this.eclipseProductId; - } - - public void setInitialPerspectiveId( final String initialPerspectiveId ) { - this.initialPerspectiveId = initialPerspectiveId; - } - - public String getInitialPerspectiveId() { - return this.initialPerspectiveId; - } - - /** - * Creates a list of available feature versions from all given update sites. - * Required features with no version number (0.0.0) are replaced with the - * highest available version number. - */ - public IStatus checkFeatures( final IProgressMonitor monitor ) - throws CoreException - { - MultiStatus result = new MultiStatus( Activator.PLUGIN_ID, IStatus.OK, null, null ); - FeatureVersionRepository availableFeatures = new FeatureVersionRepository(); - List<VersionedIdentifier> newRequiredFeatures = new ArrayList<VersionedIdentifier>(); - createFeatureRepository( monitor, availableFeatures ); - for( VersionedIdentifier featureIdentifier : this.requiredFeatures ) { - - VersionedIdentifier newIdentifier = featureIdentifier; - String featureId = featureIdentifier.getIdentifier(); - Version featureVersion = new Version( featureIdentifier.getVersion().toString() ); - - if( ! availableFeatures.containsIdentifier( featureId ) ) { - String message = "Feature " //$NON-NLS-1$ - + featureId - + " not available on given update sites."; //$NON-NLS-1$ - result.add( new Status( IStatus.WARNING, Activator.PLUGIN_ID, message ) ); - } else { - Version highestVersion = availableFeatures.getHighestVersion( featureId ); - String newVersion = highestVersion.toString(); - - if( Version.emptyVersion.equals( featureVersion ) ) - { - String message = "Replacing feature version of " //$NON-NLS-1$ - + featureId - + " with version " //$NON-NLS-1$ - + newVersion; - result.add( new Status( IStatus.INFO, Activator.PLUGIN_ID, message ) ); - newIdentifier = new VersionedIdentifier( featureId, newVersion ); - } else { - if( highestVersion.compareTo( featureVersion ) > 0 ) { - String message = "Higher version of feature " //$NON-NLS-1$ - + featureId - + " available: " //$NON-NLS-1$ - + newVersion; - result.add( new Status( IStatus.INFO, Activator.PLUGIN_ID, message ) ); - } - if( highestVersion.compareTo( featureVersion ) < 0 ) { - String message = "Only lower version of feature " //$NON-NLS-1$ - + featureId - + " available: " //$NON-NLS-1$ - + newVersion; - result.add( new Status( IStatus.WARNING, Activator.PLUGIN_ID, message ) ); - } - } - } - - newRequiredFeatures.add( newIdentifier ); - } - this.requiredFeatures = newRequiredFeatures; - return result; - } - - - // internal methods - /////////////////// - - - private void createFeatureRepository( final IProgressMonitor monitor, - final FeatureVersionRepository availableFeatures ) - throws CoreException - { - for( URL url : this.updateSites ) { - ISite site = SiteManager.getSite( url, monitor ); - ISiteFeatureReference[] featureReferences = site.getFeatureReferences(); - for( ISiteFeatureReference featureReference : featureReferences ) { - VersionedIdentifier versionedIdentifier = featureReference.getVersionedIdentifier(); - availableFeatures.addVersionIdentifier( versionedIdentifier ); - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Platform.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Platform.java deleted file mode 100644 index befcb660..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Platform.java +++ /dev/null @@ -1,138 +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.configuration; - -import static org.eclipse.core.runtime.Platform.ARCH_X86; -import static org.eclipse.core.runtime.Platform.ARCH_X86_64; -import static org.eclipse.core.runtime.Platform.OS_LINUX; -import static org.eclipse.core.runtime.Platform.OS_WIN32; -import static org.eclipse.core.runtime.Platform.WS_GTK; -import org.eclipse.update.core.SiteManager; - -/** - * Represents a platform configuration, consisting of operating system (os), - * windowing system (ws) and system architecture (arch). Default implementation - * of IPlatform. - */ -public class Platform implements IPlatform { - - private final String os; - private final String ws; - private final String arch; - private final String eclipseIniFileContent; - private final String eclipseIniFilePath; - private ArchiveFormat archiveFormat = ArchiveFormat.antZip; - - public Platform( final String os, - final String ws, - final String arch, - final String eclipseIniFileContent, - final String eclipseIniFilePath ) - { - this.os = os; - this.ws = ws; - this.arch = arch; - this.eclipseIniFileContent = eclipseIniFileContent; - this.eclipseIniFilePath = eclipseIniFilePath; - } - - @Override - public boolean equals( final Object obj ) { - boolean result = false; - if( obj instanceof Platform ) { - Platform other = ( Platform )obj; - result = os.equals( other.os ) - && ws.equals( other.ws ) - && arch.equals( other.arch ); - } - return result; - } - - public String toString( final char separator ) { - return os + separator + ws + separator + arch; - } - - /** Identical with toString(',) */ - @Override - public String toString() { - return toString( ',' ); - } - - public ArchiveFormat getArchiveFormat() { - return archiveFormat; - } - - public void setArchiveFormat( final String format ) { - this.archiveFormat = ArchiveFormat.valueOf( format ); - } - - public void configureSite() { - SiteManager.setOS( os ); - SiteManager.setWS( ws ); - SiteManager.setOSArch( arch ); - } - - // Requires PDE Build with up-to-date unzippergenerator. - public String getRootFileName( final IPackagerConfiguration configuration ) { - StringBuilder builder = new StringBuilder( configuration.getRootFileBaseName() ); - builder.append( os ); - boolean isWin32 = isWin32(); - if( !isWin32 ) { - builder.append( '-' ); - builder.append( ws ); - } - boolean isLinuxGtk = isLinux() && WS_GTK.endsWith( ws ); - if( ( isWin32 || isLinuxGtk ) && !isX86() ) { - builder.append( '-' ); - builder.append( arch ); - } - builder.append( archiveFormat.getExtension() ); - return builder.toString(); - } - - private boolean isLinux() { - return OS_LINUX.equals( os ); - } - - private boolean isX86() { - return ARCH_X86.equals( arch ); - } - - private boolean isWin32() { - return OS_WIN32.equals( os ); - } - - public String getTargetFileName( final IPackagerConfiguration configuration ) - { - return configuration.getProductName() + "-" //$NON-NLS-1$ - + toString( '.' ); - } - - public String getInstallScriptName() { - String buildFile; - boolean isWin32x86 = isWin32() && isX86(); - boolean isLinuxX86 = isLinux() && ( isX86() || ARCH_X86_64.equals( arch ) ); - if( ( isWin32x86 || isLinuxX86 ) ) { - buildFile = "build-installer-" + os + ".xml"; //$NON-NLS-1$ //$NON-NLS-2$ - } else { - buildFile = "build-installer-default.xml"; //$NON-NLS-1$ - } - return buildFile; - } - - public String getEclipseIniFileContent() { - return eclipseIniFileContent; - } - - public String getEclipseIniFilePath() { - return eclipseIniFilePath; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Task.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Task.java deleted file mode 100644 index 4a863132..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/Task.java +++ /dev/null @@ -1,23 +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.configuration; - -/** - * Enumerates the three tasks known to the Eclipse Packager. - */ -public enum Task { - /** Verifies requested features against the installation sites. */ - CHECK, - /** Installs the requested features to the local extension site. */ - INSTALL, - /** Builds the application from the requested features and the root files. */ - BUILD -}
\ No newline at end of file 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 deleted file mode 100644 index dd1edf7e..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser.java +++ /dev/null @@ -1,217 +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.configuration.xml; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; - -import javax.xml.parsers.ParserConfigurationException; - -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.PackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.Platform; -import org.xml.sax.SAXException; - -/** - * Parses an Eclipse Packager configuration in XML format. - */ -public class ConfigurationParser { - - private static final String LATEST = "latest"; //$NON-NLS-1$ - - private static final String ATTRIB_ARCH = "arch"; //$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_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 final File xmlFile; - - public ConfigurationParser( final File xmlFile ) { - this.xmlFile = xmlFile; - } - - /** - * Parses the configuration contained in xmlFile. - */ - public IPackagerConfiguration parseConfiguration() - throws SAXException, IOException, ParserConfigurationException - { - return parseConfiguration( new XMLDocument( xmlFile ).getRootElement() ); - } - - /** - * Parses the configuration-string xml. Used in tests only. - */ - public IPackagerConfiguration parseConfiguration( final String xml ) - throws MalformedURLException, SAXException, IOException, - ParserConfigurationException - { - 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. - * - * @throws MalformedURLException - */ - private IPackagerConfiguration parseConfiguration( final IXmlElement root ) - throws MalformedURLException - { - PackagerConfiguration configuration = new PackagerConfiguration(); - parseRcp( configuration, root ); - parseProduct( configuration, root ); - parseUpdateSites( configuration, root ); - parseRequiredFeatures( configuration, root ); - parseRootFolder( configuration, root ); - parseExtensionSite( configuration, root ); - parsePlatforms( configuration, root ); - return configuration; - } - - - /** 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 target platforms. */ - private void parsePlatforms( final PackagerConfiguration configuration, - final IXmlElement parent ) - { - IXmlElement element = parent.getElement( TAG_TARGET_PLATFORMS ); - for( IXmlElement platformElement : getElements( element, TAG_PLATFORM ) ) { - String os = platformElement.getAttributeValue( ATTRIB_OS ); - String ws = platformElement.getAttributeValue( ATTRIB_WS ); - String arch = platformElement.getAttributeValue( ATTRIB_ARCH ); - IXmlElement eclipseIniFileElement = platformElement.getElement( TAG_ECLIPSE_INI_FILE ); - String eclipseIniFileContent = eclipseIniFileElement.getText(); - String eclipseIniFilePath = eclipseIniFileElement.getAttributeValue( ATTRIB_ECLIPSE_INI_PATH ); - Platform platform = configuration.addTargetPlatform( os, ws, arch, eclipseIniFileContent, eclipseIniFilePath ); - IXmlElement archiveFormat = platformElement.getElement( TAG_ARCHIVE_FORMAT ); - if( archiveFormat != null ) { - platform.setArchiveFormat( archiveFormat.getAttributeValue( ATTRIB_FORMAT ) ); - } - } - } - - 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 ) - { - IXmlElement element = parent.getElement( TAG_REQUIRED_FEATURES ); - for( IXmlElement featureElement : getElements( element, TAG_FEATURE ) ) { - String version = featureElement.getAttributeValue( ATTRIB_VERSION ); - if( version != null ) { - version = version.trim(); - if( version.length() == 0 || LATEST.equalsIgnoreCase( version ) ) { - version = null; - } - } - configuration.addRequiredFeature( featureElement.getAttributeValue( ATTRIB_ID ), - version ); - } - } - - /** 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. - * - * @throws MalformedURLException - */ - private void parseUpdateSites( final PackagerConfiguration configuration, - final IXmlElement parent ) - throws MalformedURLException - { - IXmlElement element = parent.getElement( TAG_UPDATE_SITES ); - for( IXmlElement siteElement : getElements( element, TAG_UPDATE_SITE ) ) { - configuration.addUpdateSite( siteElement.getAttributeValue( ATTRIB_URL ) ); - } - } - - /* - * 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 deleted file mode 100644 index f5981b00..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/IXmlElement.java +++ /dev/null @@ -1,48 +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.configuration.xml; - -/** An XML Element with sub elements and attributes. */ -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 text value of this element without any preprocessing. - * - * @return text of this XML element - */ - 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 deleted file mode 100644 index 6268629c..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XMLDocument.java +++ /dev/null @@ -1,76 +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.configuration.xml; - -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; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -/** - * 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 - { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = docBuilderFactory.newDocumentBuilder(); - this.document = documentBuilder.parse( xmlFile ); - } - - /** - * 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 - { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = docBuilderFactory.newDocumentBuilder(); - ByteArrayInputStream inputStream = new ByteArrayInputStream( xmlString.getBytes() ); - this.document = documentBuilder.parse( inputStream ); - } - - /** - * 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 )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 deleted file mode 100644 index 1c740c67..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/xml/XmlElement.java +++ /dev/null @@ -1,60 +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.configuration.xml; - -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -/** XML Element implementation using an underlying W3C DOM Element. */ -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 IXmlElement getElement( final String tagName ) { - NodeList elementsByTagName = this.node.getElementsByTagName( tagName ); - IXmlElement result; - if( elementsByTagName.getLength() == 0 ) { - result = null; - } else { - result = new XmlElement( ( Element )elementsByTagName.item( 0 ) ); - } - return result; - } - - public IXmlElement[] getElements( final String 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 ) ) ); - } - 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(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/ExtensionSiteManager.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/ExtensionSiteManager.java deleted file mode 100644 index e3b3e1fd..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/ExtensionSiteManager.java +++ /dev/null @@ -1,57 +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.download; - -import java.io.File; -import java.io.IOException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.configuration.IPlatform; -import org.eclipse.epp.packaging.core.logging.MessageLogger; -import org.eclipse.update.configuration.IConfiguredSite; -import org.eclipse.update.core.IFeature; - -/** - * Responsible for creating the extension site and installing the features - * provided by an UpdateSiteManager - */ -public class ExtensionSiteManager { - - private final IPackagerConfiguration configuration; - - public ExtensionSiteManager( final IPackagerConfiguration configuration ) { - this.configuration = configuration; - } - - public void installFeatures( final IUpdateSiteManager manager ) - throws IOException, CoreException - { - File localSiteFolder = this.configuration.getExtensionSite(); - MessageLogger.getInstance().log( "ExtensionSiteManager.SiteCreated", //$NON-NLS-1$ - localSiteFolder ); - IConfiguredSite site = SiteCreator.createInstallationSite( localSiteFolder ); - for( IPlatform platform : this.configuration.getTargetPlatforms() ) { - MessageLogger.getInstance().logBeginProcess( "ExtensionSiteManager.InstallPlatform", //$NON-NLS-1$ - platform ); - platform.configureSite(); - for( IFeature feature : manager.getFeatures() ) { - String identifier = feature.getVersionedIdentifier().getIdentifier(); - MessageLogger.getInstance().logBeginProcess( "ExtensionSiteManager.Installing", //$NON-NLS-1$ - identifier ); - site.install( feature, null, new NullProgressMonitor() ); - MessageLogger.getInstance().logEndProcess(); - } - MessageLogger.getInstance().logEndProcess(); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureRetrievingSearchCollector.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureRetrievingSearchCollector.java deleted file mode 100644 index 4556fc9b..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureRetrievingSearchCollector.java +++ /dev/null @@ -1,40 +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.download; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.update.core.IFeature; -import org.eclipse.update.core.VersionedIdentifier; -import org.eclipse.update.search.IUpdateSearchResultCollector; - -/** - * An UpdateSearchResultCollector returning a feature. - */ -public class FeatureRetrievingSearchCollector - implements IUpdateSearchResultCollector -{ - - private final List<IFeature> features = new ArrayList<IFeature>(); - private final List<VersionedIdentifier> identifiers = new ArrayList<VersionedIdentifier>(); - - public void accept( final IFeature match ) { - if( !this.identifiers.contains( match.getVersionedIdentifier() ) ) { - this.features.add( match ); - this.identifiers.add( match.getVersionedIdentifier() ); - } - } - - public IFeature[] getFeatures() { - return this.features.toArray( new IFeature[ this.features.size() ] ); - } -} diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureSearcher.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureSearcher.java deleted file mode 100644 index a50453d2..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureSearcher.java +++ /dev/null @@ -1,55 +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.download; - -import java.net.URL; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.update.core.VersionedIdentifier; -import org.eclipse.update.search.IUpdateSearchResultCollector; -import org.eclipse.update.search.UpdateSearchRequest; -import org.eclipse.update.search.UpdateSearchScope; - -/** - * Handles and executes the search for a set of features over a number of update - * sites. - */ -public class FeatureSearcher { - - private final UpdateSearchScope scope = new UpdateSearchScope(); - private final PackagerSearchCategory category = new PackagerSearchCategory(); - - public FeatureSearcher( final VersionedIdentifier[] listedFeatures, - final URL[] listedSites ) - { - for( VersionedIdentifier identifier : listedFeatures ) { - this.category.addFeatureToSearch( identifier ); - } - for( URL siteUrl : listedSites ) { - this.scope.addSearchSite( "", siteUrl, null ); //$NON-NLS-1$ - } - } - - /** - * Run the search. - * - * @param collector the collector storing the search results. - */ - public void run( final IUpdateSearchResultCollector collector ) - throws OperationCanceledException, CoreException - { - UpdateSearchRequest searchRequest - = new UpdateSearchRequest( this.category, this.scope ); - searchRequest.performSearch( collector, new NullProgressMonitor() ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureVerifyingSearchCollector.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureVerifyingSearchCollector.java deleted file mode 100644 index 57bb752b..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/FeatureVerifyingSearchCollector.java +++ /dev/null @@ -1,53 +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.download; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.update.core.IFeature; -import org.eclipse.update.core.VersionedIdentifier; -import org.eclipse.update.search.IUpdateSearchResultCollector; - -/** - * UpdateSearchResultCollector comparing features found with a base set of - * features to find. - */ -public class FeatureVerifyingSearchCollector - implements IUpdateSearchResultCollector -{ - - private final List<VersionedIdentifier> featuresToFind = new ArrayList<VersionedIdentifier>(); - - public FeatureVerifyingSearchCollector( final VersionedIdentifier[] listedFeatures ) - { - Collections.addAll( this.featuresToFind, listedFeatures ); - } - - public void accept( final IFeature feature ) { - this.featuresToFind.remove( feature.getVersionedIdentifier() ); - } - - /** - * @return true if all the configured features are found, false otherwise. - */ - public boolean allFeaturesFound() { - return this.featuresToFind.isEmpty(); - } - - /** - * @return the list of missing features - */ - public VersionedIdentifier[] getMissingFeatures() { - return this.featuresToFind.toArray( new VersionedIdentifier[ this.featuresToFind.size() ] ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/IUpdateSiteManager.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/IUpdateSiteManager.java deleted file mode 100644 index 3213ba1f..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/IUpdateSiteManager.java +++ /dev/null @@ -1,35 +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.download; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.update.core.IFeature; -import org.eclipse.update.core.VersionedIdentifier; - -/** - * Responsible for managing the declared update sites. - */ -public interface IUpdateSiteManager { - - /** - * Checks whether all of the features given by identifiers are present on the - * managed update sites. - * - * @return true, if all identified features can be found, false otherwise. - */ - public boolean areFeaturesPresent( VersionedIdentifier[] identifiers ) - throws CoreException; - - /** - * Returns the IFeatures for the configured feature references - */ - public IFeature[] getFeatures() throws CoreException; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/PackagerSearchCategory.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/PackagerSearchCategory.java deleted file mode 100644 index eb9332a0..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/PackagerSearchCategory.java +++ /dev/null @@ -1,45 +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.download; - -import org.eclipse.update.core.VersionedIdentifier; -import org.eclipse.update.search.IUpdateSearchCategory; -import org.eclipse.update.search.IUpdateSearchQuery; - -/** - * An UpdateSearchCategory looking for feature identifiers - */ -public class PackagerSearchCategory implements IUpdateSearchCategory { - - private final PackagerSearchQuery query = new PackagerSearchQuery(); - private String id; - - public String getId() { - return this.id; - } - - /** - * Adds a feature to search for. - */ - public void addFeatureToSearch( final VersionedIdentifier identifier ) { - this.query.addFeatureIdentifier( identifier ); - } - - public IUpdateSearchQuery[] getQueries() { - return new IUpdateSearchQuery[]{ - this.query - }; - } - - public void setId( final String id ) { - this.id = id; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/PackagerSearchQuery.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/PackagerSearchQuery.java deleted file mode 100644 index bd5942bf..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/PackagerSearchQuery.java +++ /dev/null @@ -1,62 +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.download; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.update.core.ISite; -import org.eclipse.update.core.ISiteFeatureReference; -import org.eclipse.update.core.VersionedIdentifier; -import org.eclipse.update.search.IQueryUpdateSiteAdapter; -import org.eclipse.update.search.IUpdateSearchFilter; -import org.eclipse.update.search.IUpdateSearchQuery; -import org.eclipse.update.search.IUpdateSearchResultCollector; - -/** - * Search query looking for occurrences of configured features. - */ -public class PackagerSearchQuery implements IUpdateSearchQuery { - - private final List<VersionedIdentifier> identifiers = new ArrayList<VersionedIdentifier>(); - - public IQueryUpdateSiteAdapter getQuerySearchSite() { - return null; - } - - public void run( final ISite site, - final String[] categoriesToSkip, - final IUpdateSearchFilter filter, - final IUpdateSearchResultCollector collector, - final IProgressMonitor monitor ) - { - ISiteFeatureReference[] featureReferences = site.getFeatureReferences(); - for( ISiteFeatureReference reference : featureReferences ) { - try { - if( this.identifiers.contains( reference.getVersionedIdentifier() ) ) { - collector.accept( reference.getFeature( new NullProgressMonitor() ) ); - } - } catch( CoreException ce ) { - // The search is over, and there is nothing we could do about it. - } - } - } - - /** - * Add a feature to look for. - */ - public void addFeatureIdentifier( final VersionedIdentifier identifier ) { - this.identifiers.add( identifier ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/SiteCreator.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/SiteCreator.java deleted file mode 100644 index af8f7313..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/SiteCreator.java +++ /dev/null @@ -1,64 +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.download; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.epp.packaging.core.io.FileUtils; -import org.eclipse.update.configuration.IConfiguredSite; -import org.eclipse.update.configuration.IInstallConfiguration; -import org.eclipse.update.configuration.ILocalSite; -import org.eclipse.update.core.SiteManager; - -/** - * Responsible for creating and deleting extension sites. - */ -public class SiteCreator { - - /** - * Adds a new extension site to the system and configures it to be able to - * update. - */ - public static IConfiguredSite createInstallationSite( final File folder ) - throws IOException, CoreException - { - if( !folder.exists() ) { - folder.mkdir(); - } - IInstallConfiguration config = SiteManager.getLocalSite() - .getCurrentConfiguration(); - IConfiguredSite site = config.createConfiguredSite( folder ); - site.verifyUpdatableStatus(); - config.addConfiguredSite( site ); - return site; - } - - /** - * Removes an extension site from the system, deleting its content. - */ - public static void removeInstallationSite( final String siteString ) - throws CoreException, MalformedURLException - { - ILocalSite localSite = SiteManager.getLocalSite(); - IInstallConfiguration configuration = localSite.getCurrentConfiguration(); - IConfiguredSite[] sites = configuration.getConfiguredSites(); - File file = new File( siteString ); - String fileUrl = file.toURL().toExternalForm() + "eclipse/";//$NON-NLS-1$ - for( IConfiguredSite site : sites ) { - if( site.getSite().getURL().toExternalForm().equals( fileUrl ) ) { - configuration.removeConfiguredSite( site ); - FileUtils.deleteFile( file ); - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/UpdateSiteManager.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/UpdateSiteManager.java deleted file mode 100644 index 050bf139..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/download/UpdateSiteManager.java +++ /dev/null @@ -1,70 +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.download; - -import java.net.URL; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration; -import org.eclipse.epp.packaging.core.logging.MessageLogger; -import org.eclipse.update.core.IFeature; -import org.eclipse.update.core.VersionedIdentifier; -import org.eclipse.update.search.IUpdateSearchResultCollector; - -/** - * Holds references to a list of update sites and provides the methods required - * for interaction. - */ -public class UpdateSiteManager implements IUpdateSiteManager { - - private final URL[] listedSites; - private final VersionedIdentifier[] listedFeatures; - - public UpdateSiteManager( final IPackagerConfiguration configuration ) { - this.listedSites = configuration.getUpdateSites(); - this.listedFeatures = configuration.getRequiredFeatures(); - MessageLogger.getInstance().log( "UpdateSiteManager.ListedSitesCount", //$NON-NLS-1$ - Integer.valueOf( this.listedSites.length ) ); - } - - public boolean areFeaturesPresent( final VersionedIdentifier[] identifiers ) - throws CoreException - { - MessageLogger.getInstance().logBeginProcess( "UpdateSiteManager.FeatureLookup" ); //$NON-NLS-1$ - FeatureVerifyingSearchCollector collector - = new FeatureVerifyingSearchCollector( this.listedFeatures ); - search( collector ); - boolean result = collector.allFeaturesFound(); - if( result ) { - MessageLogger.getInstance().logEndProcess( "UpdateSiteManager.FeaturesPresent" ); //$NON-NLS-1$ - } else { - MessageLogger.getInstance().logEndProcess( "UpdateSiteManager.FeaturesMissing" ); //$NON-NLS-1$ - for( VersionedIdentifier feature : collector.getMissingFeatures() ) { - MessageLogger.getInstance().log( feature.toString() ); - } - } - return result; - } - - public IFeature[] getFeatures() throws CoreException { - FeatureRetrievingSearchCollector collector = new FeatureRetrievingSearchCollector(); - search( collector ); - return collector.getFeatures(); - } - - private void search( final IUpdateSearchResultCollector collector ) - throws CoreException - { - FeatureSearcher featureSearcher = new FeatureSearcher( this.listedFeatures, - this.listedSites ); - featureSearcher.run( collector ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/io/FileUtils.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/io/FileUtils.java deleted file mode 100644 index 201a1923..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/io/FileUtils.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.io; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; - -/** - * Utility class for file operation. - */ -public class FileUtils { - - /** - * Copies source to destination. - * - * @param source The source file. - * @param destination The destination file. - */ - public static void copy( final File source, final File destination ) - throws IOException - { - if( !source.exists() ) { - return; - } - createDestinationFolder( destination ); - FileChannel inputChannel = null; - FileChannel outputChannel = null; - try { - inputChannel = new FileInputStream( source ).getChannel(); - outputChannel = new FileOutputStream( destination ).getChannel(); - inputChannel.transferTo( 0, inputChannel.size(), outputChannel ); - } finally { - if( inputChannel != null ) { - inputChannel.close(); - } - if( outputChannel != null ) { - outputChannel.close(); - } - } - } - - /** - * Copies source to destination. - * - * @param source Path to the source file. - * @param destination Path to the destination file. - */ - public static void copy( final String source, final String destination ) - throws IOException - { - File sourceFile = new File( source ); - copy( sourceFile, new File( destination ) ); - } - - /** Creates parent folders, if not existing. */ - private static void createDestinationFolder( final File destinationFile ) { - File destinationParent = destinationFile.getParentFile(); - if( !destinationParent.exists() ) { - destinationParent.mkdirs(); - } - } - - /** Recursively deletes a file or folder. */ - public static void deleteFile( final File file ) { - if( file.isDirectory() ) { - for( File subFile : file.listFiles() ) { - deleteFile( subFile ); - } - } - file.delete(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/io/Zip.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/io/Zip.java deleted file mode 100644 index 76704ffd..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/io/Zip.java +++ /dev/null @@ -1,146 +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.io; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -/** - * Capsules creation of archives in ZIP format. Begin with constructor, add - * content, finally end creation with close(). - */ -public class Zip { - - private final ZipOutputStream zipOutputStream; - - /** - * Opens a new zip archive in the location denoted by file and readies it for - * writing. - * - * @param file the zip archive file that is used for writing - * @throws FileNotFoundException - */ - public Zip( final File file ) throws FileNotFoundException { - this.zipOutputStream = new ZipOutputStream( new FileOutputStream( file ) ); - } - - public Zip( final File sourceFolder, final String fileName ) - throws FileNotFoundException - { - this( new File( sourceFolder, fileName ) ); - } - - /** - * Adds a file to the zip archive. - * - * @param relativePath The relative path to the file to add. - */ - public void addFile( final String relativePath ) throws IOException { - File file = new File( relativePath ); - addFileAs( file, relativePath ); - } - - /** - * Adds the contents of a folder to the zip archive. - * - * @param folder The folder to add. If the file is not a folder, nothing - * happens. - */ - public void addFolder( final File folder ) throws IOException { - if( folder.isDirectory() ) { - addDirectoryContents( folder, folder ); - } - } - - /** - * Adds a file or folder to the archive. * - * - * @param file The file or folder to add. - * @param rootContainer The parent directory. All files' paths are made - * relative to this folder. - */ - private void addFile( final File file, final File rootContainer ) - throws IOException - { - if( file.isDirectory() ) { - addDirectoryContents( file, rootContainer ); - } else { - String path = file.getCanonicalPath(); - String entryName - = path.replace( rootContainer.getCanonicalPath(), "." );//$NON-NLS-1$ - addFileAs( file, entryName ); - } - } - - /** - * Adds the given file to the archive. - * - * @param file The file to add. - * @param entryName The path under which to store the file. - */ - public void addFileAs( final File file, final String entryName ) - throws IOException, FileNotFoundException - { - String name = entryName; - if( entryName.startsWith( "./" ) ) {//$NON-NLS-1$ - name = name.replaceFirst( "./", "" );//$NON-NLS-1$//$NON-NLS-2$ - } - if( entryName.startsWith( ".\\" ) ) {//$NON-NLS-1$ - name = name.replaceFirst( ".\\\\", "" );//$NON-NLS-1$//$NON-NLS-2$ - } - this.zipOutputStream.putNextEntry( new ZipEntry( name ) ); - writeFileToZip( new FileInputStream( file ) ); - this.zipOutputStream.closeEntry(); - } - - /** - * Closes the zip file. No further additions are possible. - * - * @throws IOException if the file couldn't be closed - */ - public void close() throws IOException { - this.zipOutputStream.close(); - } - - /** - * Adds all subfiles of the given directory to the archive. Paths are made - * relative to rootContainer. - * - * @param file The directory to add. - * @param rootContainer The parent directory. All files' paths are made - * relative to this folder. - */ - private void addDirectoryContents( final File file, final File rootContainer ) - throws IOException - { - for( File subFile : file.listFiles() ) { - addFile( subFile, rootContainer ); - } - } - - /** - * Writes the given InputStream to the ZipOutputStream - */ - private void writeFileToZip( final InputStream inStream ) throws IOException { - byte[] buffer = new byte[ 512 ]; - int lengthRead = 0; - while( ( lengthRead = inStream.read( buffer ) ) != -1 ) { - this.zipOutputStream.write( buffer, 0, lengthRead ); - } - inStream.close(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/Logger.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/Logger.java deleted file mode 100644 index 32eb4d8c..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/Logger.java +++ /dev/null @@ -1,77 +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.logging; - -import java.util.HashMap; -import java.util.Map; - -/** - * A logger with basic process handling facilities. - */ -public class Logger { - - private int processCount = 0; - private Map<Integer, Boolean> subProcesses = new HashMap<Integer, Boolean>(); - private boolean justEndedProcess = false; - - /** Log a single event */ - public void log( final String message ) { - createNewEntry( message ); - justEndedProcess = true; - } - - /** Log the beginning of an ongoing process. */ - public void logBeginProcess( final String message ) { - createNewEntry( message ); - System.out.print( "..." );//$NON-NLS-1$ - processCount++; - memorizeProcess( Boolean.FALSE ); - justEndedProcess = false; - } - - private void createNewEntry( final String message ) { - memorizeProcess( Boolean.TRUE ); - System.out.println(); - indent(); - System.out.print( message ); - } - - private void memorizeProcess( final Boolean value ) { - subProcesses.put( getProcessCount(), value ); - } - - /** Indent to indicate sub-processes. */ - private void indent() { - for( int index = 0; index < processCount; index++ ) { - System.out.print( " " ); //$NON-NLS-1$ - } - } - - public void logEndProcess( final String message ) { - if( processCount > 0 ) { - if( justEndedProcess ) { - System.out.println(); - } - boolean booleanValue = subProcesses.get( getProcessCount() ) - .booleanValue(); - processCount--; - if( booleanValue ) { - indent(); - } - System.out.print( message ); - justEndedProcess = true; - } - } - - private Integer getProcessCount() { - return Integer.valueOf( processCount ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/MessageLogger.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/MessageLogger.java deleted file mode 100644 index 83f09475..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/MessageLogger.java +++ /dev/null @@ -1,64 +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.logging; - -/** - * Combines logging and i18n into a single class. - */ -public class MessageLogger { - - private final static MessageLogger instance = new MessageLogger(); - private final Logger logger = new Logger(); - - public static MessageLogger getInstance() { - return instance; - } - - public void log( final String messageKey ) { - logger.log( getI18nedMessage( messageKey ) ); - } - - public void log( final String messageKey, final Object argument ) { - logger.log( getI18nedMessage( messageKey, argument ) ); - } - - public void logBeginProcess( final String messageKey ) { - logger.logBeginProcess( getI18nedMessage( messageKey ) ); - } - - public void logBeginProcess( final String messageKey, final Object argument ) - { - logger.logBeginProcess( getI18nedMessage( messageKey, argument ) ); - } - - - private String getI18nedMessage( final String message ) { - return Messages.getString( message ); - } - - private String getI18nedMessage( final String messageKey, - final Object argument ) - { - return Messages.getString( messageKey, argument ); - } - - public void logEndProcess() { - logger.logEndProcess(Messages.getString( "Logger.Done" )); //$NON-NLS-1$ - } - - public void logEndProcess( final String messageKey ) { - logger.logEndProcess( getI18nedMessage( messageKey ) ); - } - - public void logEndProcess( final String messageKey, final Object argument ) { - logger.logEndProcess( getI18nedMessage( messageKey, argument ) ); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/Messages.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/Messages.java deleted file mode 100644 index a43bd855..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/Messages.java +++ /dev/null @@ -1,57 +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.logging; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** Utility class providing basic internationalization facilities. */ -public class Messages { - - private static final String BUNDLE_NAME = "org.eclipse.epp.packaging.core.logging.messages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages() { - // private constructor - } - - /** - * Returns the value associated with the given key, or a placeholder if the - * key does not exist. - */ - public static String getString( final String key ) { - String result; - try { - result = RESOURCE_BUNDLE.getString( key ); - } catch( MissingResourceException e ) { - result = '!' + key + '!'; - } - return result; - } - - /** - * Returns the value associated with the given key, using it as a message. - * - * @param key An internationalization key defined in a resource file. Should - * denote a message. - * @param argument The argument to insert into the message. - */ - public static String getString( final String key, final Object argument ) { - Object[] messageArgument = { - argument - }; - MessageFormat formatter = new MessageFormat( "" ); //$NON-NLS-1$ - formatter.applyPattern( getString( key ) ); - String output = formatter.format( messageArgument ); - return output; - } -} 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 deleted file mode 100644 index 505482f6..00000000 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/logging/messages.properties +++ /dev/null @@ -1,16 +0,0 @@ -Application.FeatureCount={0} features listed. -UpdateSiteManager.ListedSitesCount={0} sites listed. -UpdateSiteManager.FeatureLookup=Looking up features -UpdateSiteManager.FeaturesPresent=All features accounted for. -UpdateSiteManager.FeaturesMissing=Could not locate all of the requested features. A list of missing features follows: -Application.Installing=Installing features -ExtensionSiteManager.SiteCreated=Created installation site at {0}. -ExtensionSiteManager.InstallPlatform=Installing features for platform {0} -ExtensionSiteManager.Installing=Installing feature {0} -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.Running=Building -PackageMover.MovingFiles=Moving Files -Logger.Done=Done.
\ No newline at end of file |