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 sink.section1_();
112
113
114 sink.body_();
115 sink.flush();
116 sink.close();
117 }
118
119
120
121
122
123
124
125 public void generateDependenciesTable( Sink sink, Iterator<Artifact> iter )
126 {
127 sink.table();
128
129 sink.tableRow();
130 sink.tableCell();
131 sink.bold();
132 sink.text( "GroupId" );
133 sink.bold_();
134 sink.tableCell_();
135
136 sink.tableCell();
137 sink.bold();
138 sink.text( "ArtifactId" );
139 sink.bold_();
140 sink.tableCell_();
141
142 sink.tableCell();
143 sink.bold();
144 sink.text( "Version" );
145 sink.bold_();
146 sink.tableCell_();
147
148 sink.tableCell();
149 sink.bold();
150 sink.text( "Scope" );
151 sink.bold_();
152 sink.tableCell_();
153
154 sink.tableCell();
155 sink.bold();
156 sink.text( "Classifier" );
157 sink.bold_();
158 sink.tableCell_();
159
160 sink.tableCell();
161 sink.bold();
162 sink.text( "Type" );
163 sink.bold_();
164 sink.tableCell_();
165
166 sink.tableCell();
167 sink.bold();
168 sink.text( "Optional" );
169 sink.bold_();
170 sink.tableCell_();
171
172 sink.tableRow_();
173 while ( iter.hasNext() )
174 {
175 Artifact artifact = iter.next();
176
177 sink.tableRow();
178 sink.tableCell();
179 sink.text( artifact.getGroupId() );
180 sink.tableCell_();
181 sink.tableCell();
182 sink.text( artifact.getArtifactId() );
183 sink.tableCell_();
184 sink.tableCell();
185 sink.text( artifact.getVersion() );
186 sink.tableCell_();
187 sink.tableCell();
188 sink.text( artifact.getScope() );
189 sink.tableCell_();
190 sink.tableCell();
191 sink.text( artifact.getClassifier() );
192 sink.tableCell_();
193 sink.tableCell();
194 sink.text( artifact.getType() );
195 sink.tableCell_();
196 sink.tableCell();
197 if ( artifact.isOptional() )
198 {
199 sink.text( "" );
200 }
201 else
202 {
203 sink.text( "false" );
204 }
205
206 sink.tableCell_();
207 sink.tableRow_();
208 }
209
210 sink.table_();
211 sink.horizontalRule();
212 }
213 }