1 package org.codehaus.mojo.macker;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugin.MojoFailureException;
24
25 import java.io.File;
26 import java.io.IOException;
27
28 import net.innig.macker.event.ListenerException;
29 import net.innig.macker.event.MackerIsMadException;
30 import net.innig.macker.rule.RuleSeverity;
31 import net.innig.macker.rule.RulesException;
32 import net.innig.macker.structure.ClassParseException;
33
34
35
36
37 public class LinkedMacker
38 implements Macker
39 {
40 private final net.innig.macker.Macker macker = new net.innig.macker.Macker();
41
42 public void addClass( File clazz )
43 throws IOException, MojoExecutionException
44 {
45 try
46 {
47 macker.addClass( clazz );
48 }
49 catch ( ClassParseException ex )
50 {
51 throw new MojoExecutionException( "Macker problem parsing a class: " + ex.getMessage(), ex );
52 }
53 }
54
55 public void addRulesFile( File rule )
56 throws IOException, MojoExecutionException
57 {
58 try
59 {
60 macker.addRulesFile( rule );
61 }
62 catch ( RulesException ex )
63 {
64 throw new MojoExecutionException( "Macker rules are not properly defined: " + ex.getMessage(), ex );
65 }
66 }
67
68 public void check()
69 throws MojoExecutionException, MojoFailureException
70 {
71 try
72 {
73 macker.check();
74 }
75 catch ( MackerIsMadException ex )
76 {
77 throw new MojoFailureException( "MackerIsMadException during Macker execution: " + ex.getMessage() );
78 }
79 catch ( RulesException ex )
80 {
81 throw new MojoExecutionException( "Macker rules are not properly defined: " + ex.getMessage(), ex );
82 }
83 catch ( ListenerException ex )
84 {
85 throw new MojoExecutionException( "Error during Macker execution: " + ex.getMessage(), ex );
86 }
87 }
88
89 public void setAngerThreshold( String anger )
90 {
91 macker.setAngerThreshold( RuleSeverity.fromName( anger ) );
92 }
93
94 public void setPrintMaxMessages( int maxMsg )
95 {
96 macker.setPrintMaxMessages( maxMsg );
97 }
98
99 public void setPrintThreshold( String print )
100 {
101 macker.setPrintThreshold( RuleSeverity.fromName( print ) );
102 }
103
104 public void setVariable( String name, String value )
105 {
106 macker.setVariable( name, value );
107 }
108
109 public void setVerbose( boolean verbose )
110 {
111 macker.setVerbose( verbose );
112 }
113
114 public void setXmlReportFile( File report )
115 {
116 macker.setXmlReportFile( report );
117 }
118
119 }