KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > tools > ComponentMetaMavenMojo


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */

17 package org.apache.avalon.fortress.tools;
18
19 import java.util.ArrayList JavaDoc;
20
21 import org.apache.maven.plugin.MojoExecutionException;
22 import org.apache.maven.plugin.MojoFailureException;
23 import org.apache.maven.plugin.logging.Log;
24
25 /**
26  * The Maven-2 plugin to extract Fortress meta-data from Java sources.
27  *
28  * @author <a HREF="mailto:dev@excalibur.apache.org">The Excalibur Team</a>
29  * @version CVS $Revision: 1.1 $ $Date: 2005/12/25 08:29:44 $
30  *
31  *
32  * @author The Excalibur Team
33  * @version $Id$
34  * @goal collect-metainfo
35  * @description Extracts Fortress Meta-information from annotations in .java files
36  * @phase compile
37  */

38  public class ComponentMetaMavenMojo extends AbstractQDoxMojo
39 {
40
41      /**
42       * Wrap Maven plugin logger
43       */

44      private class MavenBuildLogger implements BuildLogger
45     {
46         private Log m_logger;
47
48         private MavenBuildLogger()
49         {
50             //Disallow use, must use construcor below that supplies Maven logger
51
}
52
53         public MavenBuildLogger( Log logger )
54         {
55             m_logger = logger;
56         }
57
58         public void debug( String JavaDoc message )
59         {
60             m_logger.debug( message );
61         }
62
63         public void error( String JavaDoc message )
64         {
65             m_logger.error( message );
66         }
67
68         public void info( String JavaDoc message )
69         {
70             m_logger.info( message );
71         }
72
73         public void warn( String JavaDoc message )
74         {
75             m_logger.warn( message );
76         }
77     }
78
79     public void execute() throws MojoExecutionException, MojoFailureException
80     {
81
82         validate();
83
84         getLog().info( "Writing Info descriptors as property files (.meta)." );
85
86         super.execute();
87
88         ComponentMetaInfoCollector collector = new ComponentMetaInfoCollector( new MavenBuildLogger( getLog() ) );
89         collector.setAllClasses( getAllClasses() );
90         collector.setDestDir( getDestDir() );
91         try
92         {
93             collector.execute();
94         }
95         catch ( Exception JavaDoc e )
96         {
97             throw new MojoExecutionException( e.getMessage(), e );
98         }
99     }
100
101     private ArrayList JavaDoc getAllClasses()
102     {
103         return allClasses;
104     }
105
106     private void validate()
107     {
108     }
109
110 }
111
Popular Tags