EMMA Coverage Report (generated Wed Dec 16 17:19:59 CET 2009)
[all classes][org.sourceforge.xradar.ant]

COVERAGE SUMMARY FOR SOURCE FILE [StaticsTask.java]

nameclass, %method, %block, %line, %
StaticsTask.java0%   (0/1)0%   (0/20)0%   (0/407)0%   (0/82)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StaticsTask0%   (0/1)0%   (0/20)0%   (0/407)0%   (0/82)
StaticsTask (): void 0%   (0/1)0%   (0/6)0%   (0/2)
addReport (Report): void 0%   (0/1)0%   (0/14)0%   (0/4)
execute (): void 0%   (0/1)0%   (0/128)0%   (0/21)
getConfig (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getJava2htmlRoot (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getJavadocEnabled (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getJavadocRoot (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getProperties (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getReports (): List 0%   (0/1)0%   (0/3)0%   (0/1)
getTarget (): String 0%   (0/1)0%   (0/3)0%   (0/1)
isDebug (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
setConfig (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
setDebug (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
setJava2htmlRoot (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
setJavadocEnabled (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
setJavadocRoot (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
setProperties (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
setReports (List): void 0%   (0/1)0%   (0/4)0%   (0/2)
setTarget (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
validate (): void 0%   (0/1)0%   (0/203)0%   (0/31)

1/**
2 * BSD-style license; for more info see http://xradar.sourceforge.net/license.html
3 */
4package org.sourceforge.xradar.ant;
5 
6import java.util.ArrayList;
7import java.util.HashMap;
8import java.util.List;
9import java.util.Map;
10 
11import org.apache.tools.ant.BuildException;
12import org.apache.tools.ant.Project;
13import org.sourceforge.xradar.XRadarException;
14import org.sourceforge.xradar.config.ReleaseData;
15import org.sourceforge.xradar.config.ReleaseDataLoader;
16import org.sourceforge.xradar.statics.MergeProduct;
17import org.sourceforge.xradar.statics.Param;
18import org.sourceforge.xradar.statics.Report;
19import org.sourceforge.xradar.statics.Statics;
20import org.sourceforge.xradar.statics.renderers.XslHtmlWebsite;
21 
22/**
23 * This classe is a simple wrapper for Statics merge for Ant.
24 * Xml configuration will be :
25 *
26        <xradar-statics debug="false"
27                                              properties="${basedir}/etc/release1.properties"
28                                              config="etc/radar-config.xml"
29                                              target="${basedir}/release1/docs/"
30                                              javadocEnabled="true"
31                                              javadocRoot="${basedir}/release1/docs/api"
32                                              java2htmlRoot="${basedir}/release1/docs/xml/htmlcode">
33                          <report file="${jdepend.report.file}"                                        type="jdepend"/>
34                          <report file="${cpd.report.file}"                                                type="cpd"/>
35                          <report file="${javancss.report.file}"                                        type="javancss"/>
36                        <report file="${ckjm.report.file}"                                                type="ckjm"/>
37                          <report file="${depfind.report.file}"                                        type="depfind"/>
38                          <report file="${docs.home}/xml/test_depfind_report.xml"        type="test_depfind"/>
39                        <report file="${checkstyle.report.file}"                                type="checkstyle"/>
40                        <!--
41                                TODO:
42                                          <report file=""        type="bcc"/>
43                                        <report file=""        type="junit"/>
44                                        <report file=""        type="cobertura"/>
45                        -->
46                  </xradar-statics>
47 *
48 * Order id as xslt fields, if not set ( most likely) will be defines using the type of the tools.
49 *
50 * 
51 * @author Romain PELISSE, belaran@gmail.com
52 *
53 */
54public class StaticsTask extends AbstractXRadarAntTask
55{
56 
57        /*
58         * Fields accessible through getter/setters
59         */
60        private List<Report> reports;
61        private boolean debug;
62        private String properties;
63        private String target;
64        private String config;
65        private String javadocEnabled = "false";
66        private String javadocRoot;
67        private String java2htmlRoot;
68 
69        /*
70         * Internal fields
71         */
72        private XslHtmlWebsite staticEngine;
73 
74        public void addReport(Report report)
75        {
76                if ( this.reports == null )
77                        this.reports = new ArrayList<Report>();
78                this.reports.add(report);
79        }
80 
81        /**
82         * Execute the merges of the reports
83         */
84        @Override
85        public void execute() throws BuildException
86        {
87                validate();
88                try
89                {
90                        // Merging the report
91                        String mergedReport = this.staticEngine.executeMerge();
92                        log("XML merging result is :\n" + mergedReport,Project.MSG_VERBOSE);
93                        log("Merging data from tool's reports.", Project.MSG_INFO);
94                        // Preparing the post processing
95                        Param radarConfig = new Param(Statics.XRADAR_CONFIG_FILE,config);
96                        ReleaseData releaseData = new ReleaseDataLoader(properties).load();
97                        // Post processing
98                        log("Post processing merged files.", Project.MSG_INFO);
99                        MergeProduct products = this.staticEngine.executePostProcessing(mergedReport, releaseData, radarConfig);
100                        // Generating the website
101                        Map<String,Param> params = new HashMap<String,Param>();
102                        params.put(Statics.JAVADOC_ENABLED,new Param(Statics.JAVADOC_ENABLED,this.getJavadocEnabled()));
103                        params.put(Statics.JAVADOC_ROOT,new Param(Statics.JAVADOC_ROOT,this.getJavadocRoot()));
104                        params.put(Statics.JAVA2HTML_ROOT,new Param(Statics.JAVA2HTML_ROOT,this.getJava2htmlRoot()));
105                        params.put(Statics.XRADAR_CONFIG_FILE,radarConfig);
106                        params.put(Statics.LOG,new Param(Statics.LOG,String.valueOf(this.debug)));
107                        log("Generating static analysis website.", Project.MSG_INFO);
108                        // Still buggy, only works for images generation !
109                        this.staticEngine.generateHtmlReport(products, params);
110                        // Copying required resources
111                        this.staticEngine.copyStaticResourcesToWebSite(this.getTarget(),this.getTarget() + "/xml/api"); // FIXME: externalize this xml/api?
112                }
113                catch (XRadarException e)
114                {
115                        throw new BuildException(e);
116                }
117        }
118 
119 
120        /**
121         * Checks if settings are proper, such as:
122         * <ul>
123         *                 <li>set docs home directory based on target attribute ( TODO: check if exist)</li>
124         *                 <li>set debug level based on debug attribute</li>
125         *                 <li>TODO:Report file exists and can be read</li>
126         *                 <li>If not defined load default value for order-id and xslt file</li>
127         *                 <li>TODO:Xslt file and can be accessed through</li>
128         *                 <li>... more ?</li>
129         * </ul>
130         * @throws BuildException
131         *
132         */
133        private void validate() throws BuildException
134        {
135                // attribute validation
136                if ( "".equals(this.getTarget()) )
137                        throw new BuildException("Target field is not optionnal.");
138                if ( "".equals(this.getProperties()) )
139                        throw new BuildException("Properties field is not optionnal.");
140                if ( "".equals(this.getConfig()) )
141                        throw new BuildException("Config field is not optionnal.");
142                if ( "".equals(this.getJava2htmlRoot()) )
143                        throw new BuildException("Java2htmlRoot field is not optionnal.");
144                if ( "".equals(this.getJavadocRoot()) && Boolean.valueOf(this.javadocEnabled) )
145                        throw new BuildException("JavadocRoot field is not optionnal, if javadocEnabled is set to true.");
146 
147                // Logging settings
148                log("Debug:"+ this.debug, Project.MSG_VERBOSE);
149                log("Target:"+ this.target, Project.MSG_VERBOSE);
150                log("Properties:"+ this.properties, Project.MSG_VERBOSE);
151                log("Config:"+ this.config, Project.MSG_VERBOSE);
152                // Setting the engine
153                this.staticEngine = new XslHtmlWebsite();
154                this.staticEngine.initializedXmlCatalog(super.isOffline());
155                this.staticEngine.setDebug(this.debug);
156                this.staticEngine.setConfig(this.config);
157                // Setting (and creating docs-home)
158                try
159                {
160                        this.staticEngine.setDocsHome(this.getTarget());
161                }
162                catch (XRadarException e)
163                {
164                        throw new BuildException(e);
165                }
166                // Adding and validating the reports ( validation delegated to the engine)
167                for ( Report report : reports )
168                {
169                        // Logging the added report data
170                        log("Report:"+ report.getType(), Project.MSG_VERBOSE);
171                        log("->Input file:" + report.getFile(), Project.MSG_VERBOSE);
172                        // Adding the report
173                        try
174                        {
175                                if ( ! this.staticEngine.addReport(report) )
176                                        log("Report " + report.getType() + " was not added, because " + report.getFile() + " does not exist or is not readable.",Project.MSG_WARN);
177                        }
178                        catch (XRadarException e)
179                        {
180                                throw new BuildException(e);
181                        }
182                }
183        }
184 
185 
186 
187        /**
188         * @return the reports
189         */
190        public List<Report> getReports() {
191                return reports;
192        }
193 
194        /**
195         * @param reports the reports to set
196         */
197        public void setReports(List<Report> reports) {
198                this.reports = reports;
199        }
200 
201        /**
202         * @return the debug
203         */
204        public boolean isDebug() {
205                return debug;
206        }
207 
208        /**
209         * @param debug the debug to set
210         */
211        public void setDebug(boolean debug) {
212                this.debug = debug;
213        }
214 
215        /**
216         * @return the properties
217         */
218        public String getProperties() {
219                return properties;
220        }
221 
222        /**
223         * @param properties the properties to set
224         */
225        public void setProperties(String properties) {
226                this.properties = properties;
227        }
228 
229        /**
230         * @return the target
231         */
232        public String getTarget() {
233                return target;
234        }
235 
236        /**
237         * @param target the target to set
238         */
239        public void setTarget(String target) {
240                this.target = target;
241        }
242 
243        /**
244         * @return the config
245         */
246        public String getConfig() {
247                return config;
248        }
249 
250        /**
251         * @param config the config to set
252         */
253        public void setConfig(String config) {
254                this.config = config;
255        }
256 
257        /**
258         * @return the java2htmlRoot
259         */
260        public String getJava2htmlRoot() {
261                return java2htmlRoot;
262        }
263 
264        /**
265         * @param java2htmlRoot the java2htmlRoot to set
266         */
267        public void setJava2htmlRoot(String java2htmlRoot) {
268                this.java2htmlRoot = java2htmlRoot;
269        }
270 
271        /**
272         * @return the javadocEnabled
273         */
274        public String getJavadocEnabled() {
275                return javadocEnabled;
276        }
277 
278        /**
279         * @param javadocEnabled the javadocEnabled to set
280         */
281        public void setJavadocEnabled(String javadocEnabled) {
282                this.javadocEnabled = javadocEnabled;
283        }
284 
285        /**
286         * @return the javadocRoot
287         */
288        public String getJavadocRoot() {
289                return javadocRoot;
290        }
291 
292        /**
293         * @param javadocRoot the javadocRoot to set
294         */
295        public void setJavadocRoot(String javadocRoot) {
296                this.javadocRoot = javadocRoot;
297        }
298}

[all classes][org.sourceforge.xradar.ant]
EMMA 2.0.5312 (C) Vladimir Roubtsov