| Line | Hits | Note | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * $Id: HTMLRenderAntTask.java 1496 2009-06-07 17:28:52Z amandel $ | ||
| 3 | * | ||
| 4 | * Copyright 2006, The jCoderZ.org Project. All rights reserved. | ||
| 5 | * | ||
| 6 | * Redistribution and use in source and binary forms, with or without | ||
| 7 | * modification, are permitted provided that the following conditions are | ||
| 8 | * met: | ||
| 9 | * | ||
| 10 | * * Redistributions of source code must retain the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer. | ||
| 12 | * * Redistributions in binary form must reproduce the above | ||
| 13 | * copyright notice, this list of conditions and the following | ||
| 14 | * disclaimer in the documentation and/or other materials | ||
| 15 | * provided with the distribution. | ||
| 16 | * * Neither the name of the jCoderZ.org Project nor the names of | ||
| 17 | * its contributors may be used to endorse or promote products | ||
| 18 | * derived from this software without specific prior written | ||
| 19 | * permission. | ||
| 20 | * | ||
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND | ||
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS | ||
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
| 28 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
| 30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| 31 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 32 | */ | ||
| 33 | package org.jcoderz.phoenix.report; | ||
| 34 | |||
| 35 | import java.io.File; | ||
| 36 | import java.nio.charset.Charset; | ||
| 37 | import java.util.ArrayList; | ||
| 38 | import java.util.List; | ||
| 39 | import java.util.logging.Logger; | ||
| 40 | |||
| 41 | import org.apache.tools.ant.BuildException; | ||
| 42 | import org.apache.tools.ant.taskdefs.MatchingTask; | ||
| 43 | import org.jcoderz.commons.util.FileUtils; | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Ant Task rendering <code>jcoderz-report.xml</code> files | ||
| 47 | * into HTML files. | ||
| 48 | * | ||
| 49 | * @author Michael Rumpf (Michael.Rumpf@jcoderz.org) | ||
| 50 | */ | ||
| 51 | 0 | public final class HTMLRenderAntTask | |
| 52 | extends MatchingTask | ||
| 53 | { | ||
| 54 | 0 | private static final String CLASSNAME = HTMLRenderAntTask.class.getName(); | |
| 55 | 0 | private static final Logger logger = Logger.getLogger(CLASSNAME); | |
| 56 | |||
| 57 | 0 | private File mBaseDir = null; | |
| 58 | /** Output directory for XML/HTML report. */ | ||
| 59 | 0 | private File mOut = null; | |
| 60 | /** The report name. */ | ||
| 61 | 0 | private String mName = null; | |
| 62 | /** The base package name. */ | ||
| 63 | 0 | private String mPackageBase = null; | |
| 64 | 0 | private Charset mSourceEncoding = null; | |
| 65 | |||
| 66 | /** | ||
| 67 | * Sets the output directory to given <code>dir</code>. | ||
| 68 | * This directory is used to store the XML/HTML report file(s). | ||
| 69 | * | ||
| 70 | * @param dir The output directory to set | ||
| 71 | */ | ||
| 72 | public void setOut (File dir) | ||
| 73 | { | ||
| 74 | 0 | mOut = dir; | |
| 75 | 0 | } | |
| 76 | |||
| 77 | (1) | public void setBaseDir (File dir) | |
| 78 | { | ||
| 79 | 0 | mBaseDir = dir; | |
| 80 | 0 | } | |
| 81 | |||
| 82 | (2) | public void setName (String name) | |
| 83 | { | ||
| 84 | 0 | mName = name; | |
| 85 | 0 | } | |
| 86 | |||
| 87 | (3) | public void setPackageBase (String pkgBase) | |
| 88 | { | ||
| 89 | 0 | mPackageBase = pkgBase; | |
| 90 | 0 | } | |
| 91 | |||
| 92 | (4) | public void setSourceEncoding (String srcEncoding) | |
| 93 | { | ||
| 94 | 0 | mSourceEncoding = Charset.forName(srcEncoding); | |
| 95 | 0 | } | |
| 96 | |||
| 97 | /** | ||
| 98 | * Execute this task. | ||
| 99 | * | ||
| 100 | * @throws BuildException An building exception occurred | ||
| 101 | */ | ||
| 102 | public void execute () | ||
| 103 | throws BuildException | ||
| 104 | { | ||
| 105 | try | ||
| 106 | { | ||
| 107 | 0 | final List<String> argList = new ArrayList<String>(); | |
| 108 | |||
| 109 | (5) | // FIXME: . is not correct if the build process was started from a | |
| 110 | // different dir (which is true in cc build) | ||
| 111 | 0 | final File outDir = mOut == null | |
| 112 | ? new File(mBaseDir , "build/report-" + mName) : mOut; | ||
| 113 | 0 | FileUtils.mkdirs(outDir); | |
| 114 | 0 | argList.add("-outDir"); | |
| 115 | 0 | argList.add(outDir.getCanonicalPath()); | |
| 116 | |||
| 117 | 0 | argList.add("-report"); | |
| 118 | 0 | final File reportFile | |
| 119 | = new File(outDir, "jcoderz-merged-report.xml"); | ||
| 120 | 0 | argList.add(reportFile.getCanonicalPath()); | |
| 121 | |||
| 122 | (6) | // FIXME: . is not correct if the build process was started from a | |
| 123 | // different dir (which is true in cc build) | ||
| 124 | 0 | argList.add("-projectHome"); | |
| 125 | 0 | argList.add(mBaseDir.getCanonicalPath()); | |
| 126 | |||
| 127 | 0 | argList.add("-projectName"); | |
| 128 | 0 | argList.add(mName); | |
| 129 | |||
| 130 | 0 | if (mPackageBase != null) | |
| 131 | { | ||
| 132 | 0 | argList.add("-packageBase"); | |
| 133 | 0 | argList.add(mPackageBase); | |
| 134 | } | ||
| 135 | |||
| 136 | 0 | if (mSourceEncoding != null) | |
| 137 | { | ||
| 138 | 0 | argList.add("-sourceEncoding"); | |
| 139 | 0 | argList.add(mSourceEncoding.name()); | |
| 140 | } | ||
| 141 | 0 | logger.fine("Calling Java2Html with args '" + argList + "'"); | |
| 142 | 0 | final String[] java2HtmlArgs | |
| 143 | (7) | = (String[]) argList.toArray(new String[argList.size()]); | |
| 144 | 0 | Java2Html.main(java2HtmlArgs); | |
| 145 | } | ||
| 146 | 0 | catch (Exception ex) | |
| 147 | { | ||
| 148 | 0 | ex.printStackTrace(); | |
| 149 | 0 | logger.severe("Could not render HTML!"); | |
| 150 | 0 | } | |
| 151 | 0 | } | |
| 152 | } |
|
|
(8) | Got an exception - java.lang.RuntimeException: Unable to get class information for @throws tag 'BuildException'. | |||
|
|
(1) | 77 | : | 4 | Missing a Javadoc comment. |
|
|
(2) | 82 | : | 4 | Missing a Javadoc comment. |
|
|
(3) | 87 | : | 4 | Missing a Javadoc comment. |
|
|
(4) | 92 | : | 4 | Missing a Javadoc comment. |
|
|
(5) | 109 | : | 0 | Comment matches to-do format '(TODO|FIXME|CHECKME)'. |
|
|
(6) | 122 | : | 0 | Comment matches to-do format '(TODO|FIXME|CHECKME)'. |
|
|
(7) | 143 | : | 15 | [cast] redundant cast to java.lang.String[] |