1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.codehaus.mojo.cobertura;
21
22 import org.apache.maven.artifact.handler.ArtifactHandler;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.codehaus.mojo.cobertura.configuration.ConfigCheck;
26 import org.codehaus.mojo.cobertura.tasks.CheckTask;
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public class CoberturaCheckMojo
41 extends AbstractCoberturaMojo
42 {
43
44
45
46
47
48
49 private ConfigCheck check;
50
51
52
53
54 public void execute()
55 throws MojoExecutionException, MojoFailureException
56 {
57 if ( skipMojo() )
58 {
59 return;
60 }
61
62 ArtifactHandler artifactHandler = getProject().getArtifact().getArtifactHandler();
63 if ( !"java".equals( artifactHandler.getLanguage() ) )
64 {
65 getLog().info(
66 "Not executing cobertura:instrument as the project is not a Java classpath-capable package" );
67 }
68 else
69 {
70 if ( !getDataFile().exists() )
71 {
72 getLog().info( "Cannot perform check, instrumentation not performed - skipping." );
73 }
74 else
75 {
76 CheckTask task = new CheckTask();
77 setTaskDefaults( task );
78 task.setConfig( check );
79 task.setDataFile( getDataFile().getAbsolutePath() );
80
81 task.execute();
82 }
83 }
84 }
85 }