File: plugin.jelly

package info (click to toggle)
libgroboutils-java 5-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,396 kB
  • ctags: 11,186
  • sloc: java: 59,748; xml: 12,762; sh: 377; perl: 104; makefile: 20
file content (227 lines) | stat: -rw-r--r-- 9,142 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?xml version="1.0"?>

<project
        xmlns:j="jelly:core"
        xmlns:ant="jelly:ant"
        xmlns:define="jelly:define"
        xmlns:maven="jelly:maven"
        xmlns:resources="resources"
        xmlns:doc="doc"
        xmlns:test="test"
        >
    
    <test:dependency-handle />
    
    
    <!-- Load external tasks -->
    
  

    <!-- ================================================================== -->
    <!-- P R E P A R E  F I L E  S Y S T E M                                -->
    <!-- ================================================================== -->

    <goal name="GroboCoverage:prepare-filesystem"
            description="Create the directory structure needed to post-compile">
        <ant:mkdir dir="${GroboCoverage.postcompile.classes}"/>
        <ant:mkdir dir="${GroboCoverage.postcompile.details}"/>
        <ant:mkdir dir="${GroboCoverage.runtime.logs}"/>
    </goal>

    <!-- ================================================================== -->
    <!-- P O S T - C O M P I L E                                            -->
    <!-- ================================================================== -->
    <goal name="GroboCoverage:post-compile"
            prereqs="java:compile, java:jar-resources
                GroboCoverage:prepare-filesystem">
        <j:choose>
            <j:when test="${sourcesPresent == 'true'}">
                <j:if test="${context.getVariable('maven.coverage.skip') != 'true'}">
                    <ant:taskdef name="GroboCoveragepostcompiler"
                        classname="net.sourceforge.groboutils.testing.codecoverage.v2.ant.CoveragePostCompilerTask"
                    />
                    <ant:GroboCoveragepostcompiler
                            outclassdir="${GroboCoverage.postcompile.classes}"
                            datadir="${GroboCoverage.postcompile.details}">
                        <u:tokenize var="modules"
                            delim=",">${GroboCoverage.postcompile.analysis}</u:tokenize>
                        <j:forEach items="${modules}" var="module"
                                indexVar="moduleNumber">
                            <ant:analysismodule name="${module}" />
                        </j:forEach>
                        <ant:fileset dir="${maven.build.dest}" />
                    </ant:GroboCoveragepostcompiler>
                    
                    
                    <!-- Create the coverage runtime class file -->
                    <ant:propertyfile
                            file="${GroboCoverage.postcompile.classes}/GroboCoverage.properties">
                        <ant:entry key="factory"
                            value="${GroboCoverage.runtime.factory}" />
                        <ant:entry key="logger.dir"
                            value="${GroboCoverage.runtime.logs}" />
                        <ant:entry key="channel-count"
                            value="5" />
                    </ant:propertyfile>
                    
                    
                    <!-- Augment the JUnit test classpath to include the
                    runtime files
                    <j:forEach var="dep" items="${pom.getPluginContext('GroboCoverage-plugin').dependencies}">
                        <j:if test="${dep.groupId == 'net.sourceforge.groboutils' and dep.id == 'GroboCodeCoverage-runtime'}">
               <j:set var="dummy" value="${thirdPartyJars.put(dep.getArtifactId(), dep)}"/>               
               <echo>${dep.id} ${dep.artifactId} ${dep.artifact} ${dep.version}</echo>
                    </j:if>
         </j:forEach>
                </j:if>
                    -->
            </j:when>
            <j:otherwise>
                <ant:echo>No java class files to post-compile.</ant:echo>
            </j:otherwise>
        </j:choose>
        
        
        <!--
        To allow for testing to run with or without coverage in the
        exact same way, we copy EVERYTHING into the classes directory, including
        resources.
        -->
        <ant:copy destdir="${GroboCoverage.postcompile.classes}"
                overwrite="false">
            <ant:fileset dir="${maven.build.dest}" />
        </ant:copy>
    </goal>
    
    

    <!-- ================================================================== -->
    <!-- R E P O R T   G O A L S                                            -->
    <!-- ================================================================== -->
    <goal name="GroboCoverage-plugin:register">
        <j:if test="${sourcesPresent == 'true'}">
            <doc:registerReport 
                name="GroboCoverage" 
                pluginName="GroboCoverage-report-plugin" 
                link="GroboCoverage/index"
                description="Unit tests code coverage report."/>
        </j:if>
    </goal>
    
    <goal name="GroboCoverage-plugin:deregister">
        <j:if test="${sourcesPresent == 'true'}">
            <doc:deregisterReport name="GroboCoverage"/>
        </j:if>
    </goal>
    
    <goal name="GroboCoverage-plugin:report">
        <attainGoal name="clover:html-report"/>
    </goal>


    <!-- ================================================================== -->
    <!-- C R E A T E  C O V E R A G E  X M L  R E P O R T                   -->
    <!-- ================================================================== -->
    <goal
        name="GroboCoverage-plugin:report"
        description="Generate a report from the coverage results">

        <j:if test="${context.getVariable('maven.coverage.skip') != 'true'}">
            <!-- Make sure that the report is generated whether the tests pass or
                not -->
            <j:set var="ignoreTestFailureOld"
                value="${maven.test.failure.ignore}"/>
            <j:set var="maven.test.failure.ignore" scope="parent" value="true"/>
            <attainGoal name="test:test"/>
            <j:set var="maven.test.failure.ignore" scope="parent"
                value="${ignoreTestFailureOld}"/>

            <!-- small work-around for test generation -->
            <ant:mkdir dir="${GroboCoverage.runtime.logs}/0"/>
            <ant:mkdir dir="${GroboCoverage.runtime.logs}/1"/>
            <ant:mkdir dir="${GroboCoverage.runtime.logs}/2"/>
            <ant:mkdir dir="${GroboCoverage.runtime.logs}/3"/>
            <ant:mkdir dir="${GroboCoverage.runtime.logs}/4"/>
            <ant:mkdir dir="${GroboCoverage.runtime.logs}/5"/>

            <ant:taskdef name="GroboCoveragereport"
                classname="net.sourceforge.groboutils.testing.codecoverage.v2.ant.CoverageReportTask"
            />
            
            <!-- Consolidate the reports into a single XML file -->
            <ant:GroboCoveragereport
                datadir="${GroboCoverage.postcompile.details}"
                logdir="${GroboCoverage.runtime.logs}"
                outdir="${GroboCoverage.coverage.dir}" />
            <ant:style
                style="${plugin.resources}/${GroboCoverage.report.xsl}"
                basedir="${GroboCoverage.coverage.dir}"
                destdir="${maven.build.dir}"
                extension=".html"
                >
                <include name="*.xml" />
            </ant:style>
        </j:if>
    </goal>
    
    

    <!-- ================================================================== -->
    <!-- T E S T   G O A L S                                                -->
    <!-- ================================================================== -->
    <!--
    For testing, we simply setup the pre and post goals for the standard
    tests to run the post-compile process, then change the maven.build.dest
    directory to be the coverage directory instead.
    -->

    <goal
        name="GroboCoverage:pretest"
        description="Setup the project for coverage generation during tests">
        
        
        <ant:path id="GroboCoverage.runtime-path">
            <ant:pathelement path="${plugin.getDependencyPath('net.sourceforge.groboutils:GroboCodeCoverage-runtime')}" />
        </ant:path>
    
        <maven:addPath id="maven.dependency.classpath"
            refid="GroboCoverage.runtime-path"/>
        
        <j:set var="tmp" value="${GroboCoverage.postcompile.classes}" />
        ${pom.getPluginContext('maven-test-plugin').setVariable('maven.build.dest',tmp)}
    </goal>


    
     <preGoal name="test:test"
            prereqs="GroboCoverage:post-compile, GroboCoverage:pretest">
    </preGoal>
    
    
    
    <preGoal name="test:ui"
            prereqs="GroboCoverage:post-compile, GroboCoverage:pretest">
    </preGoal>
    
    
    
    <preGoal name="test:single"
            prereqs="GroboCoverage:post-compile, GroboCoverage:pretest">
    </preGoal>
    
    
    
    <preGoal name="test:match"
            prereqs="GroboCoverage:post-compile, GroboCoverage:pretest">
    </preGoal>
    
    
    
    <define:taglib uri="GroboCoverage">
        <define:tag name="dependency-handle">
        <!-- XXX Use this tag to allow this plugin to be loaded into another -->
        </define:tag>
    </define:taglib>
</project>