1 18 package net.sf.uitags.build; 19 20 import java.io.File ; 21 import java.util.Iterator ; 22 import java.util.Map ; 23 24 import net.sf.uitags.build.TldUtils.Tag; 25 26 import org.apache.maven.plugin.AbstractMojo; 27 import org.apache.maven.plugin.MojoFailureException; 28 import org.w3c.dom.Document ; 29 30 36 public final class MissingBeanInfoDetector extends AbstractMojo { 37 41 46 private String tldFile; 47 52 private String sourceDir; 53 54 55 59 private Map tags; 61 62 63 67 70 private void init() { 71 Document tldDocument = TldUtils.getDocument(this.tldFile); 72 this.tags = TldUtils.extractTags(tldDocument); 73 } 74 75 76 80 public void execute() throws MojoFailureException { 81 init(); 82 83 boolean beanInfoMissing = false; 84 for (Iterator iter = this.tags.entrySet().iterator(); iter.hasNext(); ) { 85 Map.Entry entry = (Map.Entry ) iter.next(); 86 if (!assertBeanInfoExists((Tag) entry.getValue())) { 87 beanInfoMissing = true; 88 } 89 } 90 91 if (beanInfoMissing) { 92 throw new MojoFailureException( 93 "At least one bean info class is missing"); 94 } 95 } 96 97 private boolean assertBeanInfoExists(Tag tag) { 98 String tagHandler = tag.getHandlerPath(); 99 100 File handlerFile = new File ( 101 this.sourceDir + tagHandler + "BeanInfo.java"); 102 if (!handlerFile.exists()) { 103 getLog().error("Missing bean info for: " + 104 tag.getFullyQualifiedHandlerName()); 105 return false; 106 } 107 return true; 108 } 109 110 114 public static void main(String args[]) throws MojoFailureException { 115 if (args.length != 2) { 116 printUsage(); 117 } 118 119 MissingBeanInfoDetector generator = new MissingBeanInfoDetector(); 120 generator.tldFile = args[0]; 121 generator.sourceDir = args[1]; 122 generator.execute(); 123 } 124 125 private static void printUsage() { 126 System.err.println("Usage: PROGRAM TLD_FILE JAVA_SRC_DIR"); 127 System.exit(1); 128 } 129 } 130 | Popular Tags |