From bb51ffc97fb6ccd3796cd3596e402c2cebda62a8 Mon Sep 17 00:00:00 2001 From: Markus Knauer Date: Mon, 22 Oct 2007 18:22:14 +0000 Subject: * moving from PluginVersionIdentifier to Version * tell about 'newer available feature versions' * code cleanup --- .../configuration/FeatureVersionRepository.java | 21 ++++---- .../core/configuration/PackagerConfiguration.java | 56 +++++++++++++--------- 2 files changed, 43 insertions(+), 34 deletions(-) (limited to 'plugins') 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 index 7101907b..68b637b5 100644 --- 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 @@ -15,7 +15,6 @@ import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; -import org.eclipse.core.runtime.PluginVersionIdentifier; import org.eclipse.update.core.VersionedIdentifier; import org.osgi.framework.Version; @@ -29,7 +28,8 @@ public class FeatureVersionRepository { public void addVersionIdentifier( final VersionedIdentifier versionedIdentifier ) { String identifier = versionedIdentifier.getIdentifier(); - PluginVersionIdentifier version = versionedIdentifier.getVersion(); + String version = versionedIdentifier.getVersion().toString(); + if( !this.features.containsKey( identifier ) ) { this.features.put( identifier, new VersionList() ); } @@ -45,8 +45,8 @@ public class FeatureVersionRepository { * @return the highest available version number or null if the * identifier is not found. */ - public PluginVersionIdentifier getHighestVersion( final String identifier ) { - PluginVersionIdentifier result = null; + public Version getHighestVersion( final String identifier ) { + Version result = null; VersionList versionList = this.features.get( identifier ); if( versionList != null ) { result = versionList.getHighestVersion(); @@ -80,13 +80,10 @@ public class FeatureVersionRepository { * Adds a new version to the list of available versions if the version is * not yet included in the list. * - * @param versionIdentifier the version that is to be added to the list + * @param version the version that is to be added to the list */ - void addVersion( final PluginVersionIdentifier versionIdentifier ) { - Version version = new Version( versionIdentifier.getMajorComponent(), - versionIdentifier.getMinorComponent(), - versionIdentifier.getServiceComponent(), - versionIdentifier.getQualifierComponent() ); + void addVersion( final String versionString ) { + Version version = new Version( versionString ); if( !this.versions.contains( version ) ) { this.versions.add( version ); } @@ -95,8 +92,8 @@ public class FeatureVersionRepository { /** * @return the highest version number in the list */ - PluginVersionIdentifier getHighestVersion() { - return new PluginVersionIdentifier( this.versions.last().toString() ); + Version getHighestVersion() { + return this.versions.last(); } } } diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java index 2b0f1f49..c3191e1e 100644 --- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java +++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/configuration/PackagerConfiguration.java @@ -20,14 +20,13 @@ 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.PluginVersionIdentifier; import org.eclipse.core.runtime.Status; import org.eclipse.epp.packaging.core.Activator; -import org.eclipse.epp.packaging.core.logging.MessageLogger; 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 @@ -44,7 +43,6 @@ public class PackagerConfiguration implements IModifiablePackagerConfiguration { private final List updateSites = new ArrayList(); private final List targetPlatforms = new ArrayList(); private List requiredFeatures = new ArrayList(); - private File packagerConfigurationFolder; private File baseFolder; private File extensionSite; private String rcpVersion; @@ -67,7 +65,7 @@ public class PackagerConfiguration implements IModifiablePackagerConfiguration { } public VersionedIdentifier[] getRequiredFeatures() { - return this.requiredFeatures.toArray( new VersionedIdentifier[ requiredFeatures.size() ] ); + return this.requiredFeatures.toArray( new VersionedIdentifier[ this.requiredFeatures.size() ] ); } public void addRequiredFeature( final String id, final String version ) { @@ -153,8 +151,6 @@ public class PackagerConfiguration implements IModifiablePackagerConfiguration { * 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. - * - * TODO mknauer enable logging, progress monitor, check availability of feature */ public IStatus checkFeatures( final IProgressMonitor monitor ) throws CoreException @@ -164,24 +160,40 @@ public class PackagerConfiguration implements IModifiablePackagerConfiguration { List newRequiredFeatures = new ArrayList(); createFeatureRepository( monitor, availableFeatures ); for( VersionedIdentifier featureIdentifier : this.requiredFeatures ) { - PluginVersionIdentifier version = featureIdentifier.getVersion(); - String identifier = featureIdentifier.getIdentifier(); - if( new PluginVersionIdentifier( 0, 0, 0 ).equals( version ) - && availableFeatures.containsIdentifier( identifier ) ) - { - String newVersion - = availableFeatures.getHighestVersion( identifier ).toString(); - String message = "Replacing feature version of " //$NON-NLS-1$ - + identifier - + " with version " //$NON-NLS-1$ - + newVersion; - result.add( new Status( IStatus.INFO, Activator.PLUGIN_ID, message ) ); - VersionedIdentifier newVersionId = new VersionedIdentifier( identifier, - newVersion ); - newRequiredFeatures.add( newVersionId ); + + 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 { - newRequiredFeatures.add( featureIdentifier ); + 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 ) ); + } + } } + + newRequiredFeatures.add( newIdentifier ); } this.requiredFeatures = newRequiredFeatures; return result; -- cgit v1.2.3