diff --git a/WHATSNEW b/WHATSNEW index e21d91d72..b6a96382f 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -85,6 +85,7 @@ Changes that could break older environments: Fixed bugs: ----------- +* now also correctly searches the first element of the path. Bug report 39345. * ant.bat now handles classpath set to "". Bug report 38914. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java b/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java index ada1e940b..ec607c451 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005 The Apache Software Foundation + * Copyright 2001-20056 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,11 @@ import org.apache.tools.ant.types.Path; */ public class Rpm extends Task { + private static final String PATH1 = "PATH="; + private static final String PATH2 = "Path="; + private static final String PATH3 = "path="; + private static final int PATH_LEN = PATH1.length(); + /** * the spec file */ @@ -300,6 +305,8 @@ public class Rpm extends Task { * the absolute path to it - falls back to rpm * otherwise. * + * @return the command used to build RPM's + * * @since 1.6 */ protected String guessRpmBuildCommand() { @@ -307,8 +314,8 @@ public class Rpm extends Task { String path = null; for (Enumeration e = env.elements(); e.hasMoreElements();) { String var = (String) e.nextElement(); - if (var.startsWith("PATH=") || var.startsWith("Path=")) { - path = var.substring(6 /* "PATH=".length() + 1 */); + if (var.startsWith(PATH1) || var.startsWith(PATH2) || var.startsWith(PATH3)) { + path = var.substring(PATH_LEN); break; } }