diff --git a/changelog.html b/changelog.html index d7728349ea..0bce7d179b 100644 --- a/changelog.html +++ b/changelog.html @@ -67,6 +67,9 @@ Upcoming changes
  • Since 1.520, Jenkins requires Java 6 or later, breaking Maven builds set to use JDK 5. Now falls back to JVM of slave agent but sets compile/test flags to use defined JDK. (issue 18403) +
  • + Since 1.517, Maven projects using Maven 2 could not build projects using extensions depending on Apache Commons Codec. + (issue 18178)
  • Provided maven settings.xml in maven builder is lost. (issue 15976) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 31983d5ac1..2e21f8f8ea 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -30,6 +30,7 @@ import edu.umd.cs.findbugs.annotations.SuppressWarnings; import hudson.Proc.LocalProc; import hudson.model.TaskListener; import hudson.os.PosixAPI; +import hudson.util.IOException2; import hudson.util.QuotedStringTokenizer; import hudson.util.VariableResolver; import hudson.util.jna.WinIOException; @@ -72,6 +73,7 @@ import java.util.regex.Pattern; import hudson.util.jna.Kernel32Utils; import static hudson.util.jna.GNUCLibrary.LIBC; +import java.security.DigestInputStream; import org.apache.commons.codec.digest.DigestUtils; /** @@ -554,11 +556,28 @@ public class Util { * @see DigestUtils#md5Hex(InputStream) */ public static String getDigestOf(InputStream source) throws IOException { + try { + MessageDigest md5 = MessageDigest.getInstance("MD5"); + + byte[] buffer = new byte[1024]; + DigestInputStream in =new DigestInputStream(source,md5); + try { + while(in.read(buffer)>=0) + ; // simply discard the input + } finally { + in.close(); + } + return toHexString(md5.digest()); + } catch (NoSuchAlgorithmException e) { + throw new IOException2("MD5 not installed",e); // impossible + } + /* JENKINS-18178: confuses Maven 2 runner try { return DigestUtils.md5Hex(source); } finally { source.close(); } + */ } public static String getDigestOf(String text) { diff --git a/test/src/test/java/hudson/maven/MavenBuildTest.java b/test/src/test/java/hudson/maven/MavenBuildTest.java index 11af78c4ec..9dd02c337e 100755 --- a/test/src/test/java/hudson/maven/MavenBuildTest.java +++ b/test/src/test/java/hudson/maven/MavenBuildTest.java @@ -8,17 +8,16 @@ import hudson.model.StringParameterDefinition; import hudson.tasks.Maven.MavenInstallation; import hudson.tasks.test.AbstractTestResultAction; import hudson.tasks.test.AggregatedTestResultAction; -import hudson.tasks.test.TestResultProjectAction; import java.io.File; import java.io.IOException; -import java.util.List; import java.util.Map; import org.jvnet.hudson.test.Bug; import org.jvnet.hudson.test.Email; import org.jvnet.hudson.test.ExtractResourceSCM; import org.jvnet.hudson.test.HudsonTestCase; +import org.jvnet.hudson.test.SingleFileSCM; /** * @author Kohsuke Kawaguchi @@ -177,7 +176,20 @@ public class MavenBuildTest extends HudsonTestCase { AbstractTestResultAction testResultAction = moduleBuild.getTestResultAction(); assertNotNull(testResultAction); assertEquals(1, testResultAction.getTotalCount()); - } + } + + @Bug(18178) + public void testExtensionsConflictingWithCore() throws Exception { + MavenModuleSet m = createMavenProject(); + m.setMaven(configureDefaultMaven().getName()); + m.setScm(new SingleFileSCM("pom.xml", + "4.0.0" + + "ga0" + + "" + + "org.springframework.build.awsorg.springframework.build.aws.maven3.0.0.RELEASE" + + "")); + buildAndAssertSuccess(m); + } private static class TestReporter extends MavenReporter { private static final long serialVersionUID = 1L;