1 package org.apache.maven.plugins.dependency.analyze;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Iterator;
23 import java.util.ResourceBundle;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.doxia.sink.Sink;
27 import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis;
28
29
30
31
32
33 public class AnalyzeReportView
34 {
35
36
37
38
39
40
41
42 public void generateReport( ProjectDependencyAnalysis analysis, Sink sink, ResourceBundle bundle )
43 {
44 sink.head();
45 sink.title();
46 sink.text( bundle.getString( "analyze.report.header" ) );
47 sink.title_();
48 sink.head_();
49 sink.body();
50
51
52 sink.section1();
53 sink.sectionTitle1();
54 sink.text( bundle.getString( "analyze.report.mainTitle" ) );
55 sink.sectionTitle1_();
56
57
58 sink.section2();
59 sink.sectionTitle2();
60 sink.text( bundle.getString( "analyze.report.UsedDeclaredDependencies" ) );
61 sink.sectionTitle2_();
62 if ( analysis.getUsedDeclaredArtifacts().isEmpty() )
63 {
64 sink.paragraph();
65 sink.text( bundle.getString( "analyze.report.noDependency" ) );
66 sink.paragraph_();
67 sink.horizontalRule();
68 }
69 else
70 {
71 generateDependenciesTable( sink, analysis.getUsedDeclaredArtifacts().iterator() );
72 }
73 sink.section2_();
74
75
76 sink.section2();
77 sink.sectionTitle2();
78 sink.text( bundle.getString( "analyze.report.UsedUndeclaredDependencies" ) );
79 sink.sectionTitle2_();
80 if ( analysis.getUsedUndeclaredArtifacts().isEmpty() )
81 {
82 sink.paragraph();
83 sink.text( bundle.getString( "analyze.report.noDependency" ) );
84 sink.paragraph_();
85 sink.horizontalRule();
86 }
87 else
88 {
89 generateDependenciesTable( sink, analysis.getUsedUndeclaredArtifacts().iterator() );
90 }
91 sink.section2_();
92
93
94 sink.section2();
95 sink.sectionTitle2();
96 sink.text( bundle.getString( "analyze.report.UnusedDeclaredDependencies" ) );
97 sink.sectionTitle2_();
98 if ( analysis.getUnusedDeclaredArtifacts().isEmpty() )
99 {
100 sink.paragraph();
101 sink.text( bundle.getString( "analyze.report.noDependency" ) );
102 sink.paragraph_();
103 sink.horizontalRule();
104 }
105 else
106 {
107 generateDependenciesTable( sink, analysis.getUnusedDeclaredArtifacts().iterator() );
108 }
109 sink.section2_();
110
111
112 sink.section2();
113 sink.sectionTitle2();
114 sink.text( "Compile Scoped Test Dependencies" );
115 sink.sectionTitle2_();
116 if ( analysis.getTestArtifactsWithNonTestScope().isEmpty() )
117 {
118 sink.paragraph();
119 sink.text( "None" );
120 sink.paragraph_();
121 sink.horizontalRule();
122 }
123 else
124 {
125 generateDependenciesTable( sink, analysis.getTestArtifactsWithNonTestScope().iterator() );
126 }
127 sink.section2_();
128
129 sink.section1_();
130
131
132 sink.body_();
133 sink.flush();
134 sink.close();
135 }
136
137
138
139
140
141
142
143 public void generateDependenciesTable( Sink sink, Iterator<Artifact> iter )
144 {
145 sink.table();
146
147 sink.tableRow();
148 sink.tableCell();
149 sink.bold();
150 sink.text( "GroupId" );
151 sink.bold_();
152 sink.tableCell_();
153
154 sink.tableCell();
155 sink.bold();
156 sink.text( "ArtifactId" );
157 sink.bold_();
158 sink.tableCell_();
159
160 sink.tableCell();
161 sink.bold();
162 sink.text( "Version" );
163 sink.bold_();
164 sink.tableCell_();
165
166 sink.tableCell();
167 sink.bold();
168 sink.text( "Scope" );
169 sink.bold_();
170 sink.tableCell_();
171
172 sink.tableCell();
173 sink.bold();
174 sink.text( "Classifier" );
175 sink.bold_();
176 sink.tableCell_();
177
178 sink.tableCell();
179 sink.bold();
180 sink.text( "Type" );
181 sink.bold_();
182 sink.tableCell_();
183
184 sink.tableCell();
185 sink.bold();
186 sink.text( "Optional" );
187 sink.bold_();
188 sink.tableCell_();
189
190 sink.tableRow_();
191 while ( iter.hasNext() )
192 {
193 Artifact artifact = iter.next();
194
195 sink.tableRow();
196 sink.tableCell();
197 sink.text( artifact.getGroupId() );
198 sink.tableCell_();
199 sink.tableCell();
200 sink.text( artifact.getArtifactId() );
201 sink.tableCell_();
202 sink.tableCell();
203 sink.text( artifact.getVersion() );
204 sink.tableCell_();
205 sink.tableCell();
206 sink.text( artifact.getScope() );
207 sink.tableCell_();
208 sink.tableCell();
209 sink.text( artifact.getClassifier() );
210 sink.tableCell_();
211 sink.tableCell();
212 sink.text( artifact.getType() );
213 sink.tableCell_();
214 sink.tableCell();
215 if ( artifact.isOptional() )
216 {
217 sink.text( "" );
218 }
219 else
220 {
221 sink.text( "false" );
222 }
223
224 sink.tableCell_();
225 sink.tableRow_();
226 }
227
228 sink.table_();
229 sink.horizontalRule();
230 }
231 }