1 19 20 package org.netbeans.modules.j2ee.ejbjarproject; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.regex.Pattern ; 25 import org.apache.tools.ant.module.spi.AntEvent; 26 import org.apache.tools.ant.module.spi.AntLogger; 27 import org.apache.tools.ant.module.spi.AntSession; 28 import org.netbeans.api.project.Project; 29 import org.netbeans.api.project.ProjectManager; 30 import org.openide.ErrorManager; 31 import org.openide.filesystems.FileObject; 32 import org.openide.filesystems.FileUtil; 33 34 39 public final class EjbJarProjectAntLogger extends AntLogger { 40 41 42 public EjbJarProjectAntLogger() { 43 } 44 45 public boolean interestedInSession(AntSession session) { 46 return true; 50 } 51 52 private static boolean isEjbJarProject(File dir) { 53 FileObject projdir = FileUtil.toFileObject(FileUtil.normalizeFile(dir)); 54 try { 55 Project proj = ProjectManager.getDefault().findProject(projdir); 56 if (proj != null) { 57 return proj instanceof EjbJarProject; 59 } 60 } catch (IOException e) { 61 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 62 } 63 return false; 64 } 65 66 public boolean interestedInScript(File script, AntSession session) { 67 if (script.getName().equals("build-impl.xml")) { File parent = script.getParentFile(); 69 if (parent != null && parent.getName().equals("nbproject")) { File parent2 = parent.getParentFile(); 71 if (parent2 != null) { 72 return isEjbJarProject(parent2); 73 } 74 } 75 } 76 return false; 78 } 79 80 public String [] interestedInTargets(AntSession session) { 81 return AntLogger.ALL_TARGETS; 82 } 83 84 public String [] interestedInTasks(AntSession session) { 85 return AntLogger.ALL_TASKS; 87 } 88 89 public int[] interestedInLogLevels(AntSession session) { 90 return new int[] { 91 AntEvent.LOG_WARN 92 }; 93 } 94 95 public void messageLogged(AntEvent event) { 96 if (!event.isConsumed() && event.getLogLevel() == AntEvent.LOG_WARN && 98 event.getMessage().startsWith("Trying to override old definition of " + "task http://www.netbeans.org/ns/j2ee-ejbjarproject/")) { event.consume(); 101 } 102 } 103 104 } 105 | Popular Tags |