1 19 package org.apache.avalon.fortress.tools; 20 21 import java.io.File ; 22 23 import org.apache.tools.ant.BuildException; 24 import org.apache.tools.ant.Project; 25 import org.apache.tools.ant.Task; 26 27 import com.thoughtworks.qdox.ant.AbstractQdoxTask; 28 29 35 public class ComponentMetaAntTask extends AbstractQdoxTask 36 { 37 38 41 private class AntBuildLogger implements BuildLogger 42 { 43 private Task m_task; 44 45 private AntBuildLogger() 46 { 47 } 49 50 public AntBuildLogger( Task task ) 51 { 52 m_task = task; 53 } 54 55 public void debug( String message ) 56 { 57 m_task.log( message, Project.MSG_DEBUG ); 58 } 59 60 public void error( String message ) 61 { 62 m_task.log( message, Project.MSG_ERR ); 63 } 64 65 public void info( String message ) 66 { 67 m_task.log( message, Project.MSG_INFO ); 68 } 69 70 public void warn( String message ) 71 { 72 m_task.log( message, Project.MSG_WARN ); 73 } 74 } 75 76 79 private File m_destDir; 80 81 public void execute() throws BuildException 82 { 83 84 validate(); 85 86 log( "Writing Info descriptors as property files (.meta)." ); 87 super.execute(); 88 89 ComponentMetaInfoCollector collector = new ComponentMetaInfoCollector( new AntBuildLogger( this ) ); 90 collector.setAllClasses( allClasses ); 91 collector.setDestDir( m_destDir ); 92 try 93 { 94 collector.execute(); 95 } 96 catch ( Exception e ) 97 { 98 throw new BuildException( e.getMessage(), e ); 99 } 100 } 101 102 105 private void validate() 106 { 107 if ( null == m_destDir ) 108 { 109 final String message = "DestDir (" + m_destDir + ") not specified"; 110 throw new BuildException( message ); 111 } 112 113 if ( !m_destDir.isDirectory() ) 114 { 115 final String message = "DestDir (" + m_destDir + ") is not a directory."; 116 throw new BuildException( message ); 117 } 118 119 if ( !m_destDir.exists() && !m_destDir.mkdirs() ) 120 { 121 final String message = "DestDir (" + m_destDir + ") could not be created."; 122 throw new BuildException( message ); 123 } 124 } 125 126 131 public void setDestDir( final File destDir ) 132 { 133 m_destDir = destDir; 134 } 135 136 } 137 | Popular Tags |