1 package org.apache.maven.plugin.dependency;
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 public void generateReport( ProjectDependencyAnalysis analysis, Sink sink, ResourceBundle bundle )
39 {
40 sink.head();
41 sink.title();
42 sink.text( bundle.getString( "analyze.report.header" ) );
43 sink.title_();
44 sink.head_();
45 sink.body();
46
47
48 sink.section1();
49 sink.sectionTitle1();
50 sink.text( bundle.getString( "analyze.report.mainTitle" ) );
51 sink.sectionTitle1_();
52
53
54 sink.section2();
55 sink.sectionTitle2();
56 sink.text( bundle.getString( "analyze.report.UsedDeclaredDependencies" ) );
57 sink.sectionTitle2_();
58 if ( analysis.getUsedDeclaredArtifacts().isEmpty() )
59 {
60 sink.paragraph();
61 sink.text( bundle.getString( "analyze.report.noDependency" ) );
62 sink.paragraph_();
63 sink.horizontalRule();
64 }
65 else
66 {
67 @SuppressWarnings( "unchecked" )
68 Iterator<Artifact> iter = analysis.getUsedDeclaredArtifacts().iterator();
69 generateDependenciesTable( sink, iter );
70 }
71 sink.section2_();
72
73
74 sink.section2();
75 sink.sectionTitle2();
76 sink.text( bundle.getString( "analyze.report.UsedUndeclaredDependencies" ) );
77 sink.sectionTitle2_();
78 if ( analysis.getUsedUndeclaredArtifacts().isEmpty() )
79 {
80 sink.paragraph();
81 sink.text( bundle.getString( "analyze.report.noDependency" ) );
82 sink.paragraph_();
83 sink.horizontalRule();
84 }
85 else
86 {
87 @SuppressWarnings( "unchecked" )
88 Iterator<Artifact> iter = analysis.getUsedUndeclaredArtifacts().iterator();
89 generateDependenciesTable( sink, iter );
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 @SuppressWarnings( "unchecked" )
108 Iterator<Artifact> iter = analysis.getUnusedDeclaredArtifacts().iterator();
109 generateDependenciesTable( sink, iter );
110 }
111 sink.section2_();
112
113 sink.section1_();
114
115
116 sink.body_();
117 sink.flush();
118 sink.close();
119 }
120
121
122
123
124 public void generateDependenciesTable( Sink sink, Iterator<Artifact> iter )
125 {
126 sink.table();
127
128 sink.tableRow();
129 sink.tableCell();
130 sink.bold();
131 sink.text( "GroupId" );
132 sink.bold_();
133 sink.tableCell_();
134
135 sink.tableCell();
136 sink.bold();
137 sink.text( "ArtifactId" );
138 sink.bold_();
139 sink.tableCell_();
140
141 sink.tableCell();
142 sink.bold();
143 sink.text( "Version" );
144 sink.bold_();
145 sink.tableCell_();
146
147 sink.tableCell();
148 sink.bold();
149 sink.text( "Scope" );
150 sink.bold_();
151 sink.tableCell_();
152
153 sink.tableCell();
154 sink.bold();
155 sink.text( "Classifier" );
156 sink.bold_();
157 sink.tableCell_();
158
159 sink.tableCell();
160 sink.bold();
161 sink.text( "Type" );
162 sink.bold_();
163 sink.tableCell_();
164
165 sink.tableCell();
166 sink.bold();
167 sink.text( "Optional" );
168 sink.bold_();
169 sink.tableCell_();
170
171 sink.tableRow_();
172 while ( iter.hasNext() )
173 {
174 Artifact artifact = iter.next();
175
176 sink.tableRow();
177 sink.tableCell();
178 sink.text( artifact.getGroupId() );
179 sink.tableCell_();
180 sink.tableCell();
181 sink.text( artifact.getArtifactId() );
182 sink.tableCell_();
183 sink.tableCell();
184 sink.text( artifact.getVersion() );
185 sink.tableCell_();
186 sink.tableCell();
187 sink.text( artifact.getScope() );
188 sink.tableCell_();
189 sink.tableCell();
190 sink.text( artifact.getClassifier() );
191 sink.tableCell_();
192 sink.tableCell();
193 sink.text( artifact.getType() );
194 sink.tableCell_();
195 sink.tableCell();
196 if ( artifact.isOptional() )
197 {
198 sink.text( "" );
199 }
200 else
201 {
202 sink.text( "false" );
203 }
204
205 sink.tableCell_();
206 sink.tableRow_();
207 }
208
209 sink.table_();
210 sink.horizontalRule();
211 }
212 }