Skip to content

Commit

Permalink
Merge pull request #19 from Vlatombe/JENKINS-24827
Browse files Browse the repository at this point in the history
Restore jdk6 compatibility
  • Loading branch information
Vlatombe committed Jul 28, 2015
2 parents 78247d3 + 669169a commit 68fbbd1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
27 changes: 27 additions & 0 deletions pom.xml
Expand Up @@ -51,6 +51,7 @@
<dollar>$</dollar>
<openbracket>{</openbracket>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.level>6</java.level>
</properties>

<repositories>
Expand Down Expand Up @@ -293,6 +294,32 @@
</filterProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.14</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java1${java.level}</artifactId>
<version>1.0</version>
</signature>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.${java.level}</source>
<target>1.${java.level}</target>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/CollectionUtils.java
@@ -0,0 +1,21 @@
package org.jenkinsci.maven.plugins.hpi;

import java.util.Enumeration;
import java.util.NoSuchElementException;

/**
* Taken from jdk7 Collections
*/
class CollectionUtils {

public static <T> Enumeration<T> emptyEnumeration() {
return (Enumeration<T>) EmptyEnumeration.EMPTY_ENUMERATION;
}

private static class EmptyEnumeration<E> implements Enumeration<E> {
static final EmptyEnumeration<Object> EMPTY_ENUMERATION = new EmptyEnumeration<Object>();

public boolean hasMoreElements() { return false; }
public E nextElement() { throw new NoSuchElementException(); }
}
}
Expand Up @@ -2,7 +2,6 @@

import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;

/**
Expand All @@ -27,7 +26,7 @@ public Enumeration<URL> getResources(String name) throws IOException {
if (name.equals("jndi.properties")) {
return jettyClassLoader.getResources(name);
}
return Collections.emptyEnumeration();
return CollectionUtils.emptyEnumeration();
}

@Override
Expand Down

0 comments on commit 68fbbd1

Please sign in to comment.