From: Dean H. <dea...@us...> - 2005-03-07 14:22:34
|
Update of /cvsroot/ant-contrib/ant-contrib/src/net/sf/antcontrib/design In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12578/src/net/sf/antcontrib/design Modified Files: VerifyDesignDelegate.java Design.java VerifyDesign.java Log Message: fix gump build, add tests, and add ability to list errors in BuildException(for cruisecontrol) Index: VerifyDesignDelegate.java =================================================================== RCS file: /cvsroot/ant-contrib/ant-contrib/src/net/sf/antcontrib/design/VerifyDesignDelegate.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** VerifyDesignDelegate.java 7 Mar 2005 11:43:05 -0000 1.6 --- VerifyDesignDelegate.java 7 Mar 2005 14:22:22 -0000 1.7 *************** *** 60,64 **** private Vector paths = new Vector(); private boolean isCircularDesign = false; ! private boolean deleteFiles = true; private Task task; --- 60,65 ---- private Vector paths = new Vector(); private boolean isCircularDesign = false; ! private boolean deleteFiles = false; ! private boolean fillInBuildException = false; private Task task; *************** *** 101,105 **** } ! public void execute() throws BuildException { if(!designFile.exists() || designFile.isDirectory()) throw new BuildException("design attribute in verifydesign element specified an invalid file="+designFile); --- 102,110 ---- } ! public void setFillInBuildException(boolean b) { ! fillInBuildException = b; ! } ! ! public void execute() { if(!designFile.exists() || designFile.isDirectory()) throw new BuildException("design attribute in verifydesign element specified an invalid file="+designFile); *************** *** 129,133 **** if (! designErrors.isEmpty()) { ! throw new BuildException("Design check failed due to previous errors"); } --- 134,140 ---- if (! designErrors.isEmpty()) { ! if(!fillInBuildException) ! throw new BuildException("Design check failed due to previous errors"); ! throwAllErrors(); } *************** *** 157,161 **** } ! } --- 164,182 ---- } ! } ! //some auto builds like cruisecontrol can only report all the ! //standard ant task errors and the build exceptions so here ! //we need to fill in the buildexception so the errors are reported ! //correctly through those tools....though, you think ant has a hook ! //in that cruisecontrol is not using like LogListeners or something ! private void throwAllErrors() { ! String result = "Design check failed due to following errors"; ! Enumeration exceptions = designErrors.elements(); ! while(exceptions.hasMoreElements()) { ! BuildException be = (BuildException)exceptions.nextElement(); ! String message = be.getMessage(); ! result += "\n" + message; ! } ! throw new BuildException(result); } *************** *** 289,293 **** desc.visit(); } catch(BuildException e) { ! task.log("The file '" + originalClassOrJarFile.getAbsolutePath() + "' failed due to: " + e.getMessage(), Project.MSG_ERR); designErrors.addElement(e); } --- 310,314 ---- desc.visit(); } catch(BuildException e) { ! log(Design.getWrapperMsg(originalClassOrJarFile, e.getMessage()), Project.MSG_ERR); designErrors.addElement(e); } *************** *** 344,348 **** public void log(String msg, int level) { ! // VerifyDesignTest.log(msg); task.log(msg, level); } --- 365,369 ---- public void log(String msg, int level) { ! //VerifyDesignTest.log(msg); task.log(msg, level); } Index: Design.java =================================================================== RCS file: /cvsroot/ant-contrib/ant-contrib/src/net/sf/antcontrib/design/Design.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Design.java 2 Feb 2005 18:16:16 -0000 1.9 --- Design.java 7 Mar 2005 14:22:22 -0000 1.10 *************** *** 16,19 **** --- 16,20 ---- package net.sf.antcontrib.design; + import java.io.File; import java.util.HashMap; import java.util.HashSet; *************** *** 188,199 **** if(!packageName.equals(currentPackageName)) { currentPackageName = packageName; ! log.log("Evaluating package="+currentPackageName, Project.MSG_INFO); currentAliasPackage = retreivePack(packageName); //DEANDO: test this scenario if(currentAliasPackage == null) ! throw new BuildException("\nPackage="+packageName+" is not defined in the design.\n"+ ! "All packages with classes must be declared in the design file\n"+ ! "Class found in the offending package="+className, location); } log.log(" class="+className, Project.MSG_VERBOSE); --- 189,198 ---- if(!packageName.equals(currentPackageName)) { currentPackageName = packageName; ! log.log("Evaluating package="+currentPackageName+"\n", Project.MSG_INFO); currentAliasPackage = retreivePack(packageName); //DEANDO: test this scenario if(currentAliasPackage == null) ! throw new BuildException(getNoDefinitionError(className), location); } log.log(" class="+className, Project.MSG_VERBOSE); *************** *** 238,246 **** public static String getErrorMessage(String className, String dependsOnClass) { ! String s = "Package="+VerifyDesignDelegate.getPackageName(className)+" is not defined to"+ ! "\ndepend on package="+VerifyDesignDelegate.getPackageName(dependsOnClass)+ ! "\n"+className+" depends on "+dependsOnClass+" which"+ ! "\nviolates the specified design. Change your code or the design"; return s; ! } } \ No newline at end of file --- 237,259 ---- public static String getErrorMessage(String className, String dependsOnClass) { ! String s = "\nYou are violating your own design...." + ! "\nClass = "+className+" depends on\nClass = "+dependsOnClass+ ! "\nThe dependency to allow this is not defined in your design" + ! "\nPackage="+VerifyDesignDelegate.getPackageName(className)+" is not defined to depend on"+ ! "\nPackage="+VerifyDesignDelegate.getPackageName(dependsOnClass)+ ! "\nChange your code or the design\n"; return s; ! } ! ! public static String getNoDefinitionError(String className) { ! String s = "\nPackage="+VerifyDesignDelegate.getPackageName(className)+" is not defined in the design.\n"+ ! "All packages with classes must be declared in the design file\n"+ ! "Class found in the offending package="+className+"\n"; ! return s; ! } ! ! public static String getWrapperMsg(File originalFile, String message) { ! String s = "The file '" + originalFile.getAbsolutePath() + "' failed due to: " + message; ! return s; ! } } \ No newline at end of file Index: VerifyDesign.java =================================================================== RCS file: /cvsroot/ant-contrib/ant-contrib/src/net/sf/antcontrib/design/VerifyDesign.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** VerifyDesign.java 9 Feb 2005 23:54:20 -0000 1.10 --- VerifyDesign.java 7 Mar 2005 14:22:22 -0000 1.11 *************** *** 50,53 **** --- 50,57 ---- delegate.setDeleteFiles(deleteFiles); } + + public void setFillInBuildException(boolean b) { + delegate.setFillInBuildException(b); + } public void addConfiguredPath(Path path) { |