diff options
author | Alexander Kurtakov | 2017-08-18 13:25:26 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-08-18 13:31:37 +0000 |
commit | a348349ea5b00131465c536b1a324326b0c9b9c5 (patch) | |
tree | 6d7c11b996b70a9a9fac922681c8d93656d12d92 /bundles | |
parent | 5185e9c4d05feb8efb02f1a178640ccae3b33d6a (diff) | |
download | rt.equinox.p2-a348349ea5b00131465c536b1a324326b0c9b9c5.tar.gz rt.equinox.p2-a348349ea5b00131465c536b1a324326b0c9b9c5.tar.xz rt.equinox.p2-a348349ea5b00131465c536b1a324326b0c9b9c5.zip |
Bug 521119 - Move p2 publisher to Java 8
Bump minor version, add missing Override annotations, remove redundant
type declarations, try-with-resources.
Change-Id: I3ffe367e70f08236646f9cfc6728c79b97ec9d1a
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles')
23 files changed, 133 insertions, 114 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/.classpath b/bundles/org.eclipse.equinox.p2.publisher/.classpath index 64c5e31b7..eca7bdba8 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/.classpath +++ b/bundles/org.eclipse.equinox.p2.publisher/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/bundles/org.eclipse.equinox.p2.publisher/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.publisher/.settings/org.eclipse.jdt.core.prefs index fff7552a8..8b432ed13 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.equinox.p2.publisher/.settings/org.eclipse.jdt.core.prefs @@ -9,13 +9,16 @@ org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -32,7 +35,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod= org.eclipse.jdt.core.compiler.problem.discouragedReference=error org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning @@ -49,7 +52,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -58,7 +61,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore @@ -66,20 +69,22 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled @@ -94,6 +99,9 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore @@ -101,6 +109,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=error org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=error @@ -113,7 +122,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF index b1a0bfd92..0fdf355d0 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.equinox.p2.publisher;singleton:=true -Bundle-Version: 1.4.200.qualifier +Bundle-Version: 1.5.0.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.publisher.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -26,7 +26,7 @@ Export-Package: org.eclipse.equinox.internal.p2.publisher; org.eclipse.equinox.spi.p2.publisher;x-friends:="org.eclipse.equinox.p2.updatesite,org.eclipse.equinox.p2.publisher.eclipse" Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)", org.eclipse.osgi;bundle-version="3.8.0" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Import-Package: org.eclipse.equinox.app;version="1.0.0";resolution:=optional, org.eclipse.equinox.internal.p2.artifact.repository, diff --git a/bundles/org.eclipse.equinox.p2.publisher/pom.xml b/bundles/org.eclipse.equinox.p2.publisher/pom.xml index 259ba019b..fd023c012 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/pom.xml +++ b/bundles/org.eclipse.equinox.p2.publisher/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.p2.publisher</artifactId> - <version>1.4.200-SNAPSHOT</version> + <version>1.5.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Activator.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Activator.java index 46297fe5e..52e6fe843 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Activator.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -20,10 +20,12 @@ public class Activator implements BundleActivator { return context; } + @Override public void start(BundleContext bundleContext) throws Exception { Activator.context = bundleContext; } + @Override public void stop(BundleContext bundleContext) throws Exception { Activator.context = null; } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/FileSetDescriptor.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/FileSetDescriptor.java index 64527f73e..bfcc11b5d 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/FileSetDescriptor.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/FileSetDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -16,8 +16,8 @@ import java.util.*; public class FileSetDescriptor { private final String key; private String configSpec = null; - private HashSet<File> fileset = new HashSet<File>(); - private final ArrayList<String[]> permissions = new ArrayList<String[]>(); + private HashSet<File> fileset = new HashSet<>(); + private final ArrayList<String[]> permissions = new ArrayList<>(); private String links = ""; //$NON-NLS-1$ public FileSetDescriptor(String key, String configSpec) { diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/QuotedTokenizer.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/QuotedTokenizer.java index ff7ba9dd1..0972cf23c 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/QuotedTokenizer.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/QuotedTokenizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. All rights reserved. + * Copyright (c) 2009, 2017 IBM Corporation and others. 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 @@ -128,10 +128,12 @@ public class QuotedTokenizer implements Enumeration<String> { return tokenType; } + @Override public boolean hasMoreElements() { return hasMoreTokens(); } + @Override public String nextElement() { return nextToken(); } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java index 20980f1af..53752ed28 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -17,8 +17,9 @@ import java.util.*; import java.util.Map.Entry; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor; -import org.eclipse.equinox.internal.p2.core.helpers.*; +import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer; +import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; import org.eclipse.equinox.internal.p2.publisher.Activator; @@ -47,7 +48,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { public static String[] getArrayFromString(String list, String separator) { if (list == null || list.trim().equals("")) //$NON-NLS-1$ return new String[0]; - List<String> result = new ArrayList<String>(); + List<String> result = new ArrayList<>(); for (QuotedTokenizer tokens = new QuotedTokenizer(list, separator); tokens.hasMoreTokens();) { String token = tokens.nextToken().trim(); if (!token.equals("")) //$NON-NLS-1$ @@ -154,7 +155,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { * @return a collection of RequiredCapabilities representing the given IUs */ protected Collection<IRequirement> createIURequirements(Collection<? extends IVersionedId> children) { - ArrayList<IRequirement> result = new ArrayList<IRequirement>(children.size()); + ArrayList<IRequirement> result = new ArrayList<>(children.size()); for (IVersionedId next : children) { if (next instanceof IInstallableUnit) { IInstallableUnit iu = (IInstallableUnit) next; @@ -229,7 +230,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { if (advice.isEmpty()) return null; - List<InstallableUnitDescription> ius = new ArrayList<InstallableUnitDescription>(); + List<InstallableUnitDescription> ius = new ArrayList<>(); for (IAdditionalInstallableUnitAdvice entry : advice) { InstallableUnitDescription[] others = entry.getAdditionalInstallableUnitDescriptions(iu); if (others != null) @@ -311,7 +312,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { IRequirement[] requiredAdvice = entry.getRequiredCapabilities(iu); if (requiredAdvice != null) { List<IRequirement> current = iu.getRequirements(); - Set<IRequirement> resultRequiredCapabilities = new HashSet<IRequirement>(current); + Set<IRequirement> resultRequiredCapabilities = new HashSet<>(current); // remove current required capabilities that match (same name and namespace) advice. for (int j = 0; j < current.size(); j++) { @@ -342,7 +343,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { IRequirement[] metaRequiredAdvice = entry.getMetaRequiredCapabilities(iu); if (metaRequiredAdvice != null) { Collection<IRequirement> current = iu.getMetaRequirements(); - Set<IRequirement> resultMetaRequiredCapabilities = new HashSet<IRequirement>(current); + Set<IRequirement> resultMetaRequiredCapabilities = new HashSet<>(current); // remove current meta-required capabilities that match (same name and namespace) advice. for (IRequirement curr : current) { @@ -373,7 +374,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { IProvidedCapability[] providedAdvice = entry.getProvidedCapabilities(iu); if (providedAdvice != null) { Collection<IProvidedCapability> current = iu.getProvidedCapabilities(); - Set<IProvidedCapability> resultProvidedCapabilities = new HashSet<IProvidedCapability>(current); + Set<IProvidedCapability> resultProvidedCapabilities = new HashSet<>(current); for (IProvidedCapability currentProvidedCapability : current) { for (int k = 0; k < providedAdvice.length; k++) { IProvidedCapability providedCapability = providedAdvice[k]; @@ -553,6 +554,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { return queryResult; } + @Override public abstract IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor); public void setPublisherInfo(IPublisherInfo info) { diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java index 2866aa171..9a53c40e6 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * 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 @@ -38,7 +38,7 @@ public abstract class AbstractPublisherApplication implements IApplication { // of an eclipse installation; in the future the default artifact mapping declared in // SimpleArtifactRepository may change, for example, to not have a 'bundles' directory // instead of a 'plugins' directory, so a separate constant is defined and used here. - static final protected String[][] INPLACE_MAPPING_RULES = { {"(& (classifier=osgi.bundle) (format=packed)", "${repoUrl}/features/${id}_${version}.jar.pack.gz"}, //$NON-NLS-1$//$NON-NLS-2$ + static final protected String[][] INPLACE_MAPPING_RULES = {{"(& (classifier=osgi.bundle) (format=packed)", "${repoUrl}/features/${id}_${version}.jar.pack.gz"}, //$NON-NLS-1$//$NON-NLS-2$ {"(& (classifier=osgi.bundle))", "${repoUrl}/plugins/${id}_${version}.jar"}, //$NON-NLS-1$//$NON-NLS-2$ {"(& (classifier=binary))", "${repoUrl}/binary/${id}_${version}"}, //$NON-NLS-1$//$NON-NLS-2$ {"(& (classifier=org.eclipse.update.feature))", "${repoUrl}/features/${id}_${version}.jar"}}; //$NON-NLS-1$//$NON-NLS-2$ @@ -194,7 +194,7 @@ public abstract class AbstractPublisherApplication implements IApplication { if (list == null || list.length == 0) return null; - List<URI> result = new ArrayList<URI>(list.length); + List<URI> result = new ArrayList<>(list.length); if (result != null) { for (int i = 0; i < list.length; i++) { try { @@ -316,10 +316,12 @@ public abstract class AbstractPublisherApplication implements IApplication { return new Publisher(publisherInfo); } + @Override public Object start(IApplicationContext context) throws Exception { return run((String[]) context.getArguments().get("application.args")); //$NON-NLS-1$ } + @Override public void stop() { if (agentRef != null) { Activator.getContext().ungetService(agentRef); diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileAdvice.java index f22d2cb1b..9a22bf362 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileAdvice.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileAdvice.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * 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 @@ -147,37 +147,42 @@ public class AdviceFileAdvice extends AbstractAdvice implements ITouchpointAdvic return id.equals(candidateId) && version.equals(candidateVersion); } - /*(non-Javadoc) - * @see org.eclipse.equinox.p2.publisher.eclipse.ITouchpointAdvice#getTouchpointData() - */ + @Override public ITouchpointData getTouchpointData(ITouchpointData existing) { return MetadataFactory.mergeTouchpointData(existing, touchpointInstructions); } + @Override public IProvidedCapability[] getProvidedCapabilities(InstallableUnitDescription iu) { return providedCapabilities; } + @Override public IRequirement[] getRequiredCapabilities(InstallableUnitDescription iu) { return requiredCapabilities; } + @Override public IRequirement[] getMetaRequiredCapabilities(InstallableUnitDescription iu) { return metaRequiredCapabilities; } + @Override public InstallableUnitDescription[] getAdditionalInstallableUnitDescriptions(IInstallableUnit iu) { return additionalIUs; } + @Override public IUpdateDescriptor getUpdateDescriptor(InstallableUnitDescription iu) { return updateDescriptor; } + @Override public Map<String, String> getArtifactProperties(IInstallableUnit iu, IArtifactDescriptor descriptor) { return null; } + @Override public Map<String, String> getInstallableUnitProperties(InstallableUnitDescription iu) { return iuProperties; } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java index 652367d36..b28a8b081 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2009, 2017 IBM Corporation and others. 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 @@ -68,13 +68,13 @@ public class AdviceFileParser { public static final Version COMPATIBLE_VERSION = Version.createOSGi(1, 0, 0); public static final VersionRange VERSION_TOLERANCE = new VersionRange(COMPATIBLE_VERSION, true, Version.createOSGi(2, 0, 0), false); - private Map<String, String> adviceProperties = new HashMap<String, String>(); - private List<IProvidedCapability> adviceProvides = new ArrayList<IProvidedCapability>(); - private List<IRequirement> adviceRequires = new ArrayList<IRequirement>(); - private List<IRequirement> adviceMetaRequires = new ArrayList<IRequirement>(); + private Map<String, String> adviceProperties = new HashMap<>(); + private List<IProvidedCapability> adviceProvides = new ArrayList<>(); + private List<IRequirement> adviceRequires = new ArrayList<>(); + private List<IRequirement> adviceMetaRequires = new ArrayList<>(); private IUpdateDescriptor adviceUpdateDescriptor = null; - private Map<String, ITouchpointInstruction> adviceInstructions = new HashMap<String, ITouchpointInstruction>(); - private List<InstallableUnitDescription> adviceOtherIUs = new ArrayList<InstallableUnitDescription>(); + private Map<String, ITouchpointInstruction> adviceInstructions = new HashMap<>(); + private List<InstallableUnitDescription> adviceOtherIUs = new ArrayList<>(); private final Map<String, String> advice; private Iterator<String> keysIterator; @@ -93,7 +93,7 @@ public class AdviceFileParser { if (adviceVersion != null) checkAdviceVersion(adviceVersion); - List<String> keys = new ArrayList<String>(advice.keySet()); + List<String> keys = new ArrayList<>(advice.keySet()); Collections.sort(keys); keysIterator = keys.iterator(); @@ -194,7 +194,7 @@ public class AdviceFileParser { //When update.match is specified, versionRange and id are ignored IExpression expr = ExpressionUtil.parse(substituteVersionAndQualifier(match)); IMatchExpression<IInstallableUnit> matchExpression = ExpressionUtil.getFactory().matchExpression(expr); - Collection<IMatchExpression<IInstallableUnit>> descriptors = new ArrayList<IMatchExpression<IInstallableUnit>>(1); + Collection<IMatchExpression<IInstallableUnit>> descriptors = new ArrayList<>(1); descriptors.add(matchExpression); return MetadataFactory.createUpdateDescriptor(descriptors, Integer.valueOf(severity), description, (URI) null); } @@ -376,14 +376,14 @@ public class AdviceFileParser { int unitUpdateSeverity = 0; String unitUpdateDescription = null; - List<IArtifactKey> unitArtifacts = new ArrayList<IArtifactKey>(); - Map<String, String> unitProperties = new HashMap<String, String>(); - List<IRequirement> unitHostRequirements = new ArrayList<IRequirement>(); - List<IProvidedCapability> unitProvides = new ArrayList<IProvidedCapability>(); - List<IRequirement> unitRequires = new ArrayList<IRequirement>(); - List<IRequirement> unitMetaRequirements = new ArrayList<IRequirement>(); - List<ILicense> unitLicenses = new ArrayList<ILicense>(); - Map<String, ITouchpointInstruction> unitInstructions = new HashMap<String, ITouchpointInstruction>(); + List<IArtifactKey> unitArtifacts = new ArrayList<>(); + Map<String, String> unitProperties = new HashMap<>(); + List<IRequirement> unitHostRequirements = new ArrayList<>(); + List<IProvidedCapability> unitProvides = new ArrayList<>(); + List<IRequirement> unitRequires = new ArrayList<>(); + List<IRequirement> unitMetaRequirements = new ArrayList<>(); + List<ILicense> unitLicenses = new ArrayList<>(); + Map<String, ITouchpointInstruction> unitInstructions = new HashMap<>(); // updatedescriptor ?? while (current != null && current.startsWith(prefix)) { diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherResult.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherResult.java index 6563c7cf7..286ea81b3 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherResult.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherResult.java @@ -91,6 +91,7 @@ public interface IPublisherResult extends IQueryable<IInstallableUnit> { * @deprecated This method should be removed as it essentially returns a random IU * with the given ID. There are some uses for this but not many and they can use #getIUs */ + @Deprecated public IInstallableUnit getIU(String id, String type); /** diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java index 2ad155eff..68bded5ce 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -197,6 +197,7 @@ public class Publisher { this.actions = actions; } + @Override public void run(IProgressMonitor monitor) { MultiStatus finalStatus = new MultiStatus("this", 0, "publishing result", null); //$NON-NLS-1$//$NON-NLS-2$ for (int i = 0; i < actions.length; i++) { diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java index 927687592..f6dfac89e 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -23,8 +23,9 @@ public class PublisherInfo implements IPublisherInfo { private IMetadataRepository contextMetadataRepository; private IArtifactRepository contextArtifactRepository; private String[] configurations = new String[0]; - private List<IPublisherAdvice> adviceList = new ArrayList<IPublisherAdvice>(11); + private List<IPublisherAdvice> adviceList = new ArrayList<>(11); + @Override public void addAdvice(IPublisherAdvice advice) { adviceList.add(advice); } @@ -33,9 +34,10 @@ public class PublisherInfo implements IPublisherInfo { return adviceList; } + @Override @SuppressWarnings("unchecked") public <T extends IPublisherAdvice> Collection<T> getAdvice(String configSpec, boolean includeDefault, String id, Version version, Class<T> type) { - ArrayList<T> result = new ArrayList<T>(); + ArrayList<T> result = new ArrayList<>(); for (IPublisherAdvice advice : adviceList) { if (type.isInstance(advice) && advice.isApplicable(configSpec, includeDefault, id, version)) // Ideally, we would use Class.cast here but it was introduced in Java 1.5 @@ -44,22 +46,27 @@ public class PublisherInfo implements IPublisherInfo { return result; } + @Override public IArtifactRepository getArtifactRepository() { return artifactRepository; } + @Override public IMetadataRepository getMetadataRepository() { return metadataRepository; } + @Override public IArtifactRepository getContextArtifactRepository() { return contextArtifactRepository; } + @Override public IMetadataRepository getContextMetadataRepository() { return contextMetadataRepository; } + @Override public int getArtifactOptions() { return artifactOptions; } @@ -84,6 +91,7 @@ public class PublisherInfo implements IPublisherInfo { artifactOptions = value; } + @Override public String[] getConfigurations() { return configurations; } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java index cf7d2a092..9cf073c3d 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -28,6 +28,7 @@ public class PublisherResult extends IndexProvider<IInstallableUnit> implements private IIndex<IInstallableUnit> idIndex; + @Override public void addIU(IInstallableUnit iu, String type) { if (type == ROOT) rootIUs.add(iu); @@ -35,11 +36,13 @@ public class PublisherResult extends IndexProvider<IInstallableUnit> implements nonRootIUs.add(iu); } + @Override public void addIUs(Collection<IInstallableUnit> ius, String type) { for (IInstallableUnit iu : ius) addIU(iu, type); } + @Override public IInstallableUnit getIU(String id, Version version, String type) { if (type == null || type == ROOT) { IInstallableUnit result = rootIUs.get(id, version); @@ -56,6 +59,8 @@ public class PublisherResult extends IndexProvider<IInstallableUnit> implements // TODO this method really should not be needed as it just returns the first // matching IU non-deterministically. + @Deprecated + @Override public IInstallableUnit getIU(String id, String type) { if (type == null || type == ROOT) { IQueryResult<IInstallableUnit> ius = rootIUs.get(id); @@ -73,10 +78,11 @@ public class PublisherResult extends IndexProvider<IInstallableUnit> implements /** * Returns the IUs in this result with the given id. */ + @Override public Collection<IInstallableUnit> getIUs(String id, String type) { if (type == null) { // TODO can this be optimized? - ArrayList<IInstallableUnit> result = new ArrayList<IInstallableUnit>(); + ArrayList<IInstallableUnit> result = new ArrayList<>(); result.addAll(rootIUs.get(id).toUnmodifiableSet()); result.addAll(nonRootIUs.get(id).toUnmodifiableSet()); return result; @@ -88,6 +94,7 @@ public class PublisherResult extends IndexProvider<IInstallableUnit> implements return null; } + @Override public void merge(IPublisherResult result, int mode) { if (mode == MERGE_MATCHING) { addIUs(result.getIUs(null, ROOT), ROOT); @@ -101,26 +108,29 @@ public class PublisherResult extends IndexProvider<IInstallableUnit> implements } } + @Override public synchronized IIndex<IInstallableUnit> getIndex(String memberName) { if (InstallableUnit.MEMBER_ID.equals(memberName)) { if (idIndex == null) { - ArrayList<IIndex<IInstallableUnit>> indexes = new ArrayList<IIndex<IInstallableUnit>>(); + ArrayList<IIndex<IInstallableUnit>> indexes = new ArrayList<>(); indexes.add(new IdIndex(nonRootIUs)); indexes.add(new IdIndex(rootIUs)); - idIndex = new CompoundIndex<IInstallableUnit>(indexes); + idIndex = new CompoundIndex<>(indexes); } return idIndex; } return null; } + @Override public Iterator<IInstallableUnit> everything() { - ArrayList<Iterator<IInstallableUnit>> iterators = new ArrayList<Iterator<IInstallableUnit>>(); + ArrayList<Iterator<IInstallableUnit>> iterators = new ArrayList<>(); iterators.add(nonRootIUs.iterator()); iterators.add(rootIUs.iterator()); - return new CompoundIterator<IInstallableUnit>(iterators.iterator()); + return new CompoundIterator<>(iterators.iterator()); } + @Override public Object getManagedProperty(Object client, String memberName, Object key) { return null; } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java index 73bbe8f95..2a9ef4334 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java @@ -55,6 +55,7 @@ public class JREAction extends AbstractPublisherAction { this.environment = environment; } + @Override public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) { String problemMessage = NLS.bind(Messages.message_problemsWhilePublishingEE, jreLocation != null ? jreLocation : environment); resultStatus = new MultiStatus(Activator.ID, 0, problemMessage, null); @@ -100,7 +101,7 @@ public class JREAction extends AbstractPublisherAction { cu.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); cu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(configId, iu.getVersion())}); cu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE); - Map<String, String> touchpointData = new HashMap<String, String>(); + Map<String, String> touchpointData = new HashMap<>(); if (jreLocation == null || !jreLocation.isDirectory()) { touchpointData.put("install", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -131,7 +132,7 @@ public class JREAction extends AbstractPublisherAction { if (profileProperties == null) return Collections.emptyList(); - List<IProvidedCapability> result = new ArrayList<IProvidedCapability>(); + List<IProvidedCapability> result = new ArrayList<>(); result.add(PublisherHelper.createSelfCapability(id, version)); generateProvidedPackages(result); generateOsgiEESystemCapabilities(result); @@ -300,11 +301,7 @@ public class JREAction extends AbstractPublisherAction { if (jreLocation.isDirectory()) { //Look for a JRE profile file to set version and capabilities - File[] profiles = jreLocation.listFiles(new FileFilter() { - public boolean accept(File pathname) { - return pathname.getAbsolutePath().endsWith(".profile"); //$NON-NLS-1$ - } - }); + File[] profiles = jreLocation.listFiles((FileFilter) pathname -> pathname.getAbsolutePath().endsWith(".profile")); if (profiles != null && profiles.length > 0) { javaProfile = profiles[0]; } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java index ab1ca6f19..aedaac901 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -23,6 +23,7 @@ public class MergeResultsAction extends AbstractPublisherAction { this.mode = mode; } + @Override public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) { MultiStatus finalStatus = new MultiStatus(MergeResultsAction.class.getName(), 0, "publishing result", null); //$NON-NLS-1$ for (int i = 0; i < actions.length; i++) { diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java index 6bfdcf173..a83b815d1 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -48,6 +48,7 @@ public class RootFilesAction extends AbstractPublisherAction { this.createParent = createParent; } + @Override public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) { setPublisherInfo(publisherInfo); IPublisherResult innerResult = new PublisherResult(); @@ -111,7 +112,7 @@ public class RootFilesAction extends AbstractPublisherAction { cu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(configUnitId, version)}); cu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE); - Map<String, String> touchpointData = new HashMap<String, String>(); + Map<String, String> touchpointData = new HashMap<>(); String configurationData = "unzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$ touchpointData.put("install", configurationData); //$NON-NLS-1$ String unConfigurationData = "cleanupzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$ @@ -142,8 +143,8 @@ public class RootFilesAction extends AbstractPublisherAction { */ private IRootFilesAdvice getAdvice(String configSpec) { Collection<IRootFilesAdvice> advice = info.getAdvice(configSpec, true, null, null, IRootFilesAdvice.class); - ArrayList<File> inclusions = new ArrayList<File>(); - ArrayList<File> exclusions = new ArrayList<File>(); + ArrayList<File> inclusions = new ArrayList<>(); + ArrayList<File> exclusions = new ArrayList<>(); File root = null; for (IRootFilesAdvice entry : advice) { // TODO for now we simply get root from the first advice that has one diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java index 5f02f79da..f4644883c 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -40,6 +40,7 @@ public class RootIUAction extends AbstractPublisherAction { this.name = name; } + @Override public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) { this.info = publisherInfo; return generateRootIU(results); @@ -121,7 +122,7 @@ public class RootIUAction extends AbstractPublisherAction { private Collection<? extends IVersionedId> getChildren(IPublisherResult result) { // get any roots that we have accummulated so far and search for // children from the advice. - HashSet<IVersionedId> children = new HashSet<IVersionedId>(); + HashSet<IVersionedId> children = new HashSet<>(); Collection<IRootIUAdvice> rootAdvice = info.getAdvice(null, true, null, null, IRootIUAdvice.class); if (rootAdvice == null) return children; diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAdvice.java index d3479bf89..416bb9eaf 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAdvice.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUAdvice.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -26,6 +26,7 @@ public class RootIUAdvice extends AbstractAdvice implements IRootIUAdvice { this.children = children; } + @Override public Collection<? extends Object> getChildren(IPublisherResult result) { return children; } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/VersionAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/VersionAdvice.java index 2a63f5a05..9ee8b6a86 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/VersionAdvice.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/VersionAdvice.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2017 Code 9 and others. 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 @@ -21,7 +21,7 @@ import org.eclipse.equinox.p2.publisher.IPublisherAdvice; public class VersionAdvice extends AbstractAdvice implements IVersionAdvice { - Map<String, Map<String, Version>> versions = new HashMap<String, Map<String, Version>>(11); + Map<String, Map<String, Version>> versions = new HashMap<>(11); /** * Load the given namespace with version mappings from the properties file at @@ -41,19 +41,10 @@ public class VersionAdvice extends AbstractAdvice implements IVersionAdvice { namespace = "null"; //$NON-NLS-1$ Map<String, String> properties; - InputStream stream = null; - try { - stream = new BufferedInputStream(new FileInputStream(file)); + try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) { properties = CollectionUtils.loadProperties(stream); } catch (IOException e) { return; - } finally { - if (stream != null) - try { - stream.close(); - } catch (IOException e) { - //nothing - } } for (Entry<String, String> entry : properties.entrySet()) { String key = entry.getKey(); @@ -69,6 +60,7 @@ public class VersionAdvice extends AbstractAdvice implements IVersionAdvice { * @param id the item for which advice is sought * @return the version advice found or <code>null</code> if none */ + @Override public Version getVersion(String namespace, String id) { Map<String, Version> values = versions.get(namespace); // if no one says anything then don't say anything. someone else might have an opinion @@ -96,7 +88,7 @@ public class VersionAdvice extends AbstractAdvice implements IVersionAdvice { // if we are clearing values then there is nothing to do if (version == null) return; - values = new HashMap<String, Version>(); + values = new HashMap<>(); versions.put(namespace, values); } if (version == null) @@ -121,7 +113,7 @@ public class VersionAdvice extends AbstractAdvice implements IVersionAdvice { } private Map<String, Version> merge(Map<String, Version> myValues, Map<String, Version> sourceValues) { - Map<String, Version> result = new HashMap<String, Version>(myValues); + Map<String, Version> result = new HashMap<>(myValues); for (String key : sourceValues.keySet()) { if (result.get(key) == null) result.put(key, sourceValues.get(key)); diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java index 9afe42dfa..2546e1d30 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * 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 @@ -66,7 +66,7 @@ public final class LocalizationHelper { HashMap<Locale, Map<String, String>> localizations = null; if (localizationFiles != null && localizationFiles.length > 0) { - localizations = new HashMap<Locale, Map<String, String>>(localizationFiles.length); + localizations = new HashMap<>(localizationFiles.length); for (int i = 0; i < localizationFiles.length; i++) { String nextFile = localizationFiles[i]; Locale nextLocale = getLocale(LocalizationHelper.getLocaleString(nextFile, localizationFile)); @@ -90,10 +90,8 @@ public final class LocalizationHelper { } public static Map<Locale, Map<String, String>> getJarPropertyLocalizations(File root, String localizationPath, Locale defaultLocale, String[] propertyKeys) { - ZipFile jarFile = null; - Map<Locale, Map<String, String>> localizations = new HashMap<Locale, Map<String, String>>(4); - try { - jarFile = new ZipFile(root, ZipFile.OPEN_READ); + Map<Locale, Map<String, String>> localizations = new HashMap<>(4); + try (ZipFile jarFile = new ZipFile(root, ZipFile.OPEN_READ)) { for (Enumeration<? extends ZipEntry> entries = jarFile.entries(); entries.hasMoreElements();) { ZipEntry nextEntry = entries.nextElement(); String nextName = nextEntry.getName(); @@ -101,9 +99,7 @@ public final class LocalizationHelper { if (!nextEntry.isDirectory() && localeString != null) { Locale nextLocale = LocalizationHelper.getLocale(localeString); - InputStream stream = null; - try { - stream = jarFile.getInputStream(nextEntry); + try (InputStream stream = jarFile.getInputStream(nextEntry)) { Map<String, String> properties = CollectionUtils.loadProperties(stream); Map<String, String> localizedStrings = LocalizationHelper.getLocalizedProperties(propertyKeys, properties); if (localizedStrings.size() > 0) { @@ -112,22 +108,11 @@ public final class LocalizationHelper { localizations.put(nextLocale, localizedStrings); } } - } finally { - if (stream != null) - stream.close(); } } } } catch (IOException ioe) { ioe.printStackTrace(); - } finally { - if (jarFile != null) { - try { - jarFile.close(); - } catch (IOException ioe) { - // do nothing - } - } } return localizations; @@ -159,7 +144,7 @@ public final class LocalizationHelper { // Given a list of keys and the corresponding localized property set, // return a new property set with those keys and the localized values. static public Map<String, String> getLocalizedProperties(String[] propertyKeys, Map<String, String> properties) { - Map<String, String> localizedProperties = new HashMap<String, String>(); + Map<String, String> localizedProperties = new HashMap<>(); for (int i = 0; i < propertyKeys.length; i++) { String key = propertyKeys[i]; if (key != null) { @@ -173,6 +158,7 @@ public final class LocalizationHelper { public static String[] getLocalizationFiles(File localizationDir, final String filenamePrefix) { return localizationDir.list(instance.new FileFilter() { + @Override public boolean accept(File directory, String filename) { return (getLocaleString(filename, filenamePrefix) != null ? true : false); } @@ -185,9 +171,7 @@ public final class LocalizationHelper { // Nothing to do } - /* (non-Javadoc) - * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) - */ + @Override public abstract boolean accept(File directory, String filename); } diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java index bdef4f059..10c6ce315 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java @@ -151,7 +151,7 @@ public class PublisherHelper { cu.setHost(reqs); cu.setFilter(INSTALL_FEATURES_FILTER); - Map<String, String> touchpointData = new HashMap<String, String>(); + Map<String, String> touchpointData = new HashMap<>(); touchpointData.put("install", "installFeature(feature:${artifact},featureId:default,featureVersion:default)"); //$NON-NLS-1$//$NON-NLS-2$ touchpointData.put("uninstall", "uninstallFeature(feature:${artifact},featureId:default,featureVersion:default)"); //$NON-NLS-1$//$NON-NLS-2$ cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData)); @@ -173,7 +173,7 @@ public class PublisherHelper { // Create a required capability on source providers IRequirement[] reqs = new IRequirement[] {MetadataFactory.createRequirement(NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_SOURCE, VersionRange.emptyRange, null, true, true, false)}; cu.setHost(reqs); - Map<String, String> touchpointData = new HashMap<String, String>(); + Map<String, String> touchpointData = new HashMap<>(); touchpointData.put("install", "addSourceBundle(bundle:${artifact})"); //$NON-NLS-1$ //$NON-NLS-2$ touchpointData.put("uninstall", "removeSourceBundle(bundle:${artifact})"); //$NON-NLS-1$ //$NON-NLS-2$ |