Hi, I just blindly copied over a project.xml file, adjusted the POM version to 2.2.2 (the version of the project I was working on) and an unexpected / unhandled exception was thrown (a NumberFormatException). I may be a special "case" in this world, but it might actually happen to someone else ;).. I fixed this, so it will log a message to the the screen saying what is wrong and after that throwing a BuildException with the same message. I had to also print the message, since ant version 1.4 does not retrieve the Exception that is actually thrown, but it just throws the InvocationTargetException. Ant 1.5 and higher will do a better job, and actually say why the build failed. (tested it on ant 1.4, 1,5 and ant cvs head).
If you are in favoour if just ignoring the error, remove the throw new BuildException line from the diff ;) Mvgr, Martin
Index: UpdatePomCheck.java =================================================================== RCS file: /home/cvspublic/jakarta-turbine-maven/src/java/org/apache/maven/UpdatePomCheck.java,v retrieving revision 1.4 diff -u -r1.4 UpdatePomCheck.java --- UpdatePomCheck.java 28 May 2002 07:49:35 -0000 1.4 +++ UpdatePomCheck.java 30 May 2002 22:15:51 -0000 @@ -60,6 +60,7 @@ import org.apache.maven.project.Project; import org.apache.maven.executor.AbstractExecutor; +import org.apache.tools.ant.BuildException; /** * XML project descriptor validator. This tasks exposes 4 Ant properties : @@ -83,6 +84,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @author dion * @author <a href="[EMAIL PROTECTED]">Vincent Massol</a> + * @author <a href="[EMAIL PROTECTED]">Martin van den Bemt</a> * @version $Id: UpdatePomCheck.java,v 1.4 2002/05/28 07:49:35 vmassol Exp $ */ public class UpdatePomCheck extends AbstractExecutor @@ -135,18 +137,27 @@ { project.setVersion("1"); } - - if (Integer.parseInt(project.getVersion()) != - MavenConstants.POM_VERSION) + try { - getProject().setProperty("pomUpdateRequired", "true"); - getProject().setProperty("fromVersion", project.getVersion()); - getProject().setProperty("toVersion", - Integer.toString(MavenConstants.POM_VERSION)); - - log("fromVersion -> " + project.getVersion()); - log(" toVersion -> " + MavenConstants.POM_VERSION); - + if (Integer.parseInt(project.getVersion()) != + MavenConstants.POM_VERSION) + { + getProject().setProperty("pomUpdateRequired", "true"); + getProject().setProperty("fromVersion", project.getVersion()); + getProject().setProperty("toVersion", + Integer.toString(MavenConstants.POM_VERSION)); + + log("fromVersion -> " + project.getVersion()); + log(" toVersion -> " + MavenConstants.POM_VERSION); + } + } + catch(NumberFormatException nfe) + { + // we have to also log it to the screen, + // since ant 1.4 and smaller doensn't + // unwrap the InvocationTargetException. + System.out.println("ERROR!! : Specified version "+project.getVersion()+" is not a valid POM Number"); + throw new BuildException("Specified version "+project.getVersion()+" is not a valid POM Number"); } // Let the build system know that we have checked the POM.
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>