Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2015-07-14 17:30:18 -0400
committerLars Vogel2015-07-14 17:30:18 -0400
commitfc9d0ec8f5132a318b1959238ae55b8f944f7fbc (patch)
tree24ad468b211faf21135128c9f6cfaef2ecb29c69
parent0d6b69a6b78ac5b8a55894477ef5738c51a2ece4 (diff)
downloadorg.eclipse.tycho-fc9d0ec8f5132a318b1959238ae55b8f944f7fbc.tar.gz
org.eclipse.tycho-fc9d0ec8f5132a318b1959238ae55b8f944f7fbc.tar.xz
org.eclipse.tycho-fc9d0ec8f5132a318b1959238ae55b8f944f7fbc.zip
Bug 472669 - Solving a few compiler warnings (Generics) and using the
diamond operator Change-Id: Ib3d09bd11ab1ae39ac4c479c05f4040aa4190a22 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/BuildPropertiesImplTest.java12
-rw-r--r--tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/LRUCacheTest.java2
-rw-r--r--tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/BuildPropertiesImpl.java18
-rw-r--r--tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/TargetEnvironment.java4
-rw-r--r--tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java30
-rw-r--r--tycho-source-plugin/src/main/java/org/eclipse/tycho/source/AbstractSourceJarMojo.java29
6 files changed, 48 insertions, 47 deletions
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/BuildPropertiesImplTest.java b/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/BuildPropertiesImplTest.java
index d059400b3..82bad9214 100644
--- a/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/BuildPropertiesImplTest.java
+++ b/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/BuildPropertiesImplTest.java
@@ -57,7 +57,7 @@ public class BuildPropertiesImplTest {
@Override
public Set<Map.Entry<Object, Object>> entrySet() {
- List<Map.Entry<Object, Object>> sortedList = new ArrayList(super.entrySet());
+ List<Map.Entry<Object, Object>> sortedList = new ArrayList<>(super.entrySet());
Collections.sort(sortedList, new Comparator<Map.Entry<Object, Object>>() {
@Override
@@ -68,14 +68,14 @@ public class BuildPropertiesImplTest {
if (reverse) {
Collections.reverse(sortedList);
}
- return new LinkedHashSet(sortedList);
+ return new LinkedHashSet<>(sortedList);
}
}
@Test
public void testSupportedKeys() throws IOException {
- BuildPropertiesImpl buildProperties = new BuildPropertiesImpl(readProperties(new File(
- "resources/testbuild.properties")));
+ BuildPropertiesImpl buildProperties = new BuildPropertiesImpl(
+ readProperties(new File("resources/testbuild.properties")));
assertEquals("1.3", buildProperties.getJavacSource());
assertEquals("1.1", buildProperties.getJavacTarget());
assertEquals("JavaSE-1.6", buildProperties.getJreCompilationProfile());
@@ -112,8 +112,8 @@ public class BuildPropertiesImplTest {
BuildPropertiesImpl buildProperties1 = new BuildPropertiesImpl(sortedProperties);
BuildPropertiesImpl buildProperties2 = new BuildPropertiesImpl(reverseSortedProperties);
- List<String> sourceFolderKeys1 = new ArrayList<String>(buildProperties1.getJarToSourceFolderMap().keySet());
- List<String> sourceFolderKeys2 = new ArrayList<String>(buildProperties2.getJarToSourceFolderMap().keySet());
+ List<String> sourceFolderKeys1 = new ArrayList<>(buildProperties1.getJarToSourceFolderMap().keySet());
+ List<String> sourceFolderKeys2 = new ArrayList<>(buildProperties2.getJarToSourceFolderMap().keySet());
assertEquals("keyset iteration order must be stable.", sourceFolderKeys1, sourceFolderKeys2);
}
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/LRUCacheTest.java b/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/LRUCacheTest.java
index 6e4af62b7..d590f8405 100644
--- a/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/LRUCacheTest.java
+++ b/tycho-bundles/org.eclipse.tycho.core.shared.tests/src/test/java/org/eclipse/tycho/core/shared/LRUCacheTest.java
@@ -41,7 +41,7 @@ public class LRUCacheTest {
}
private Map<String, String> createPreFilledCacheSize5() {
- Map<String, String> cache = new LRUCache<String, String>(5);
+ Map<String, String> cache = new LRUCache<>(5);
cache.put("key1", "value1");
cache.put("key2", "value2");
cache.put("key3", "value3");
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/BuildPropertiesImpl.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/BuildPropertiesImpl.java
index 8dbac230a..3dbd7627e 100644
--- a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/BuildPropertiesImpl.java
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/BuildPropertiesImpl.java
@@ -47,8 +47,8 @@ public class BuildPropertiesImpl implements BuildProperties {
javacTarget = safeTrimValue("javacTarget", properties);
forceContextQualifier = safeTrimValue("forceContextQualifier", properties);
jreCompilationProfile = safeTrimValue("jre.compilation.profile", properties);
- rootFilesUseDefaultExcludes = Boolean.parseBoolean(properties.getProperty("rootFiles.useDefaultExcludes",
- "true"));
+ rootFilesUseDefaultExcludes = Boolean
+ .parseBoolean(properties.getProperty("rootFiles.useDefaultExcludes", "true"));
sourceIncludes = splitAndTrimCommaSeparated(properties.getProperty("src.includes"));
sourceExcludes = splitAndTrimCommaSeparated(properties.getProperty("src.excludes"));
@@ -57,12 +57,12 @@ public class BuildPropertiesImpl implements BuildProperties {
jarsExtraClasspath = splitAndTrimCommaSeparated(properties.getProperty("jars.extra.classpath"));
jarsCompileOrder = splitAndTrimCommaSeparated(properties.getProperty("jars.compile.order"));
- HashMap<String, List<String>> jarTosourceFolderTmp = new LinkedHashMap<String, List<String>>();
- HashMap<String, List<String>> jarToExtraClasspathTmp = new LinkedHashMap<String, List<String>>();
- HashMap<String, String> jarToJavacDefaultEncodingTmp = new LinkedHashMap<String, String>();
- HashMap<String, String> jarToOutputFolderMapTmp = new LinkedHashMap<String, String>();
- HashMap<String, String> jarToManifestMapTmp = new LinkedHashMap<String, String>();
- HashMap<String, String> rootEntriesTmp = new LinkedHashMap<String, String>();
+ HashMap<String, List<String>> jarTosourceFolderTmp = new LinkedHashMap<>();
+ HashMap<String, List<String>> jarToExtraClasspathTmp = new LinkedHashMap<>();
+ HashMap<String, String> jarToJavacDefaultEncodingTmp = new LinkedHashMap<>();
+ HashMap<String, String> jarToOutputFolderMapTmp = new LinkedHashMap<>();
+ HashMap<String, String> jarToManifestMapTmp = new LinkedHashMap<>();
+ HashMap<String, String> rootEntriesTmp = new LinkedHashMap<>();
List<String> sortedKeys = new ArrayList(properties.keySet());
Collections.sort(sortedKeys);
@@ -113,7 +113,7 @@ public class BuildPropertiesImpl implements BuildProperties {
}
private static List<String> splitAndTrimCommaSeparated(String rawValue) {
- List<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
if (rawValue != null) {
for (String element : rawValue.split(",")) {
result.add(element.trim());
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/TargetEnvironment.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/TargetEnvironment.java
index d63a3f204..596872af1 100644
--- a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/TargetEnvironment.java
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/TargetEnvironment.java
@@ -78,7 +78,7 @@ public final class TargetEnvironment {
* @return a new instance of {@link HashMap} with the target environment set
*/
public HashMap<String, String> toFilterProperties() {
- HashMap<String, String> result = new HashMap<String, String>();
+ HashMap<String, String> result = new HashMap<>();
if (os != null)
result.put(OSGI_OS, os);
@@ -96,7 +96,7 @@ public final class TargetEnvironment {
* environment.
*/
public String toFilterExpression() {
- ArrayList<String> conditions = new ArrayList<String>();
+ ArrayList<String> conditions = new ArrayList<>();
if (os != null)
conditions.add(OSGI_OS + "=" + os);
diff --git a/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java b/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java
index 928517a72..7d21e68d9 100644
--- a/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java
+++ b/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java
@@ -182,9 +182,9 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
private String proc;
/**
- * Qualified class names of annotation processors to run. If specified, the <a
- * href="http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Processor.html"
- * >normal processor discovery process</a> will be skipped. This parameter requires a 1.6 VM or
+ * Qualified class names of annotation processors to run. If specified, the
+ * <a href="http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Processor.html" >
+ * normal processor discovery process</a> will be skipped. This parameter requires a 1.6 VM or
* above and is used only if the compliance is 1.6
*
* @since 0.16.0
@@ -267,7 +267,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
protected abstract SourceInclusionScanner getSourceInclusionScanner(String inputFileEnding);
- protected abstract List getClasspathElements() throws MojoExecutionException;
+ protected abstract List<String> getClasspathElements() throws MojoExecutionException;
protected abstract List getCompileSourceRoots() throws MojoExecutionException;
@@ -316,7 +316,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
CompilerConfiguration compilerConfiguration = getCompilerConfiguration(compileSourceRoots);
// TODO: have an option to always compile (without need to clean)
- Set staleSources;
+ Set<File> staleSources;
boolean canUpdateTarget;
@@ -331,7 +331,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
// TODO: This second scan for source files is sub-optimal
String inputFileEnding = compiler.getInputFileEnding(compilerConfiguration);
- Set sources = computeStaleSources(compilerConfiguration, compiler,
+ Set<File> sources = computeStaleSources(compilerConfiguration, compiler,
getSourceInclusionScanner(inputFileEnding));
compilerConfiguration.setSourceFiles(sources);
@@ -355,8 +355,8 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
if (getLog().isDebugEnabled()) {
getLog().debug("Classpath:");
- for (Iterator it = getClasspathElements().iterator(); it.hasNext();) {
- String s = (String) it.next();
+ for (Iterator<String> it = getClasspathElements().iterator(); it.hasNext();) {
+ String s = it.next();
getLog().debug(" " + s);
}
@@ -455,7 +455,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
compilerConfiguration.setSourceEncoding(getEncoding());
if ((compilerArguments != null) || (compilerArgument != null) || compilerArgs != null) {
- LinkedHashMap cplrArgsCopy = new LinkedHashMap();
+ LinkedHashMap<String, String> cplrArgsCopy = new LinkedHashMap<String, String>();
if (compilerArguments != null) {
for (Iterator i = compilerArguments.entrySet().iterator(); i.hasNext();) {
Map.Entry me = (Map.Entry) i.next();
@@ -548,7 +548,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
return true;
}
- private Set computeStaleSources(CompilerConfiguration compilerConfiguration, Compiler compiler,
+ private Set<File> computeStaleSources(CompilerConfiguration compilerConfiguration, Compiler compiler,
SourceInclusionScanner scanner) throws MojoExecutionException, CompilerException {
CompilerOutputStyle outputStyle = compiler.getCompilerOutputStyle();
@@ -572,7 +572,7 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
scanner.addSourceMapping(mapping);
- Set staleSources = new HashSet();
+ Set<File> staleSources = new HashSet<File>();
for (Iterator it = getCompileSourceRoots().iterator(); it.hasNext();) {
String sourceRoot = (String) it.next();
@@ -586,8 +586,8 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
try {
staleSources.addAll(scanner.getIncludedSources(rootFile, outputDirectory));
} catch (InclusionScanException e) {
- throw new MojoExecutionException("Error scanning source root: \'" + sourceRoot + "\' "
- + "for stale files to recompile.", e);
+ throw new MojoExecutionException(
+ "Error scanning source root: \'" + sourceRoot + "\' " + "for stale files to recompile.", e);
}
}
@@ -598,8 +598,8 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
* @todo also in ant plugin. This should be resolved at some point so that it does not need to
* be calculated continuously - or should the plugins accept empty source roots as is?
*/
- protected static List removeEmptyCompileSourceRoots(List compileSourceRootsList) {
- List newCompileSourceRootsList = new ArrayList();
+ protected static List<String> removeEmptyCompileSourceRoots(List compileSourceRootsList) {
+ List<String> newCompileSourceRootsList = new ArrayList<>();
if (compileSourceRootsList != null) {
// copy as I may be modifying it
for (Iterator i = compileSourceRootsList.iterator(); i.hasNext();) {
diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/AbstractSourceJarMojo.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/AbstractSourceJarMojo.java
index 1e5570fe1..89987b47c 100644
--- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/AbstractSourceJarMojo.java
+++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/AbstractSourceJarMojo.java
@@ -93,8 +93,9 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
private JarArchiver jarArchiver;
/**
- * The archive configuration to use. See <a
- * href="http://maven.apache.org/shared/maven-archiver/index.html">Maven Archiver Reference</a>.
+ * The archive configuration to use. See
+ * <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven Archiver
+ * Reference</a>.
*
* @since 2.1
*/
@@ -111,7 +112,8 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
private File defaultManifestFile;
/**
- * Set this to <code>true</code> to enable the use of the <code>defaultManifestFile</code>. <br/>
+ * Set this to <code>true</code> to enable the use of the <code>defaultManifestFile</code>.
+ * <br/>
*
* @since 2.1
*/
@@ -219,20 +221,19 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
protected abstract boolean isRelevantProject(MavenProject p);
- protected void packageSources(List projects) throws MojoExecutionException {
+ protected void packageSources(List<MavenProject> projects) throws MojoExecutionException {
if (project.getArtifact().hasClassifier()) {
- getLog().warn(
- "NOT adding sources to artifacts with classifier as Maven only supports one classifier "
- + "per artifact. Current artifact [" + project.getArtifact().getId() + "] has a ["
- + project.getArtifact().getClassifier() + "] classifier.");
+ getLog().warn("NOT adding sources to artifacts with classifier as Maven only supports one classifier "
+ + "per artifact. Current artifact [" + project.getArtifact().getId() + "] has a ["
+ + project.getArtifact().getClassifier() + "] classifier.");
return;
}
MavenArchiver archiver = createArchiver();
- for (Iterator i = projects.iterator(); i.hasNext();) {
- MavenProject subProject = getProject((MavenProject) i.next());
+ for (Iterator<MavenProject> i = projects.iterator(); i.hasNext();) {
+ MavenProject subProject = getProject(i.next());
if ("pom".equals(subProject.getPackaging())) {
continue;
@@ -401,7 +402,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
* @return The combined array of includes.
*/
private String[] getCombinedIncludes(List additionalIncludes) {
- ArrayList combinedIncludes = new ArrayList();
+ ArrayList<String> combinedIncludes = new ArrayList<>();
if (includes != null && includes.length > 0) {
combinedIncludes.addAll(Arrays.asList(includes));
@@ -416,7 +417,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
combinedIncludes.addAll(Arrays.asList(DEFAULT_INCLUDES));
}
- return (String[]) combinedIncludes.toArray(new String[combinedIncludes.size()]);
+ return combinedIncludes.toArray(new String[combinedIncludes.size()]);
}
/**
@@ -429,7 +430,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
*/
private String[] getCombinedExcludes(List additionalExcludes) {
- ArrayList combinedExcludes = new ArrayList();
+ ArrayList<String> combinedExcludes = new ArrayList<String>();
if (useDefaultExcludes) {
combinedExcludes.addAll(FileUtils.getDefaultExcludesAsList());
@@ -447,6 +448,6 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo {
combinedExcludes.addAll(Arrays.asList(DEFAULT_EXCLUDES));
}
- return (String[]) combinedExcludes.toArray(new String[combinedExcludes.size()]);
+ return combinedExcludes.toArray(new String[combinedExcludes.size()]);
}
}

Back to the top