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 sink.section1_();
53 sink.lineBreak();
54
55
56 sink.section2();
57 sink.sectionTitle2();
58 sink.text( bundle.getString( "analyze.report.UsedDeclaredDependencies" ) );
59 sink.sectionTitle2_();
60 if ( analysis.getUsedDeclaredArtifacts().isEmpty() )
61 {
62 sink.text( bundle.getString( "analyze.report.noDependency" ) );
63 sink.horizontalRule();
64 }
65 else
66 {
67 Iterator iter = analysis.getUsedDeclaredArtifacts().iterator();
68 generateDependenciesTable( sink, iter );
69 }
70 sink.section2_();
71
72
73 sink.section2();
74 sink.sectionTitle2();
75 sink.text( bundle.getString( "analyze.report.UsedUndeclaredDependencies" ) );
76 sink.sectionTitle2_();
77 if ( analysis.getUsedUndeclaredArtifacts().isEmpty() )
78 {
79 sink.text( bundle.getString( "analyze.report.noDependency" ) );
80 sink.horizontalRule();
81 }
82 else
83 {
84 Iterator iter = analysis.getUsedUndeclaredArtifacts().iterator();
85 generateDependenciesTable( sink, iter );
86 }
87 sink.section2_();
88
89
90 sink.section2();
91 sink.sectionTitle2();
92 sink.text( bundle.getString( "analyze.report.UnusedDeclaredDependencies" ) );
93 sink.sectionTitle2_();
94 if ( analysis.getUnusedDeclaredArtifacts().isEmpty() )
95 {
96 sink.text( bundle.getString( "analyze.report.noDependency" ) );
97 sink.horizontalRule();
98 }
99 else
100 {
101 Iterator iter = analysis.getUnusedDeclaredArtifacts().iterator();
102 generateDependenciesTable( sink, iter );
103 }
104 sink.section2_();
105
106
107 sink.body_();
108 sink.flush();
109 sink.close();
110 }
111
112
113
114
115 public void generateDependenciesTable( Sink sink, Iterator iter )
116 {
117 sink.table();
118
119 sink.tableRow();
120 sink.tableCell();
121 sink.bold();
122 sink.text( "GroupId" );
123 sink.bold_();
124 sink.tableCell_();
125
126 sink.tableCell();
127 sink.bold();
128 sink.text( "ArtifactId" );
129 sink.bold_();
130 sink.tableCell_();
131
132 sink.tableCell();
133 sink.bold();
134 sink.text( "Version" );
135 sink.bold_();
136 sink.tableCell_();
137
138 sink.tableCell();
139 sink.bold();
140 sink.text( "Scope" );
141 sink.bold_();
142 sink.tableCell_();
143
144 sink.tableCell();
145 sink.bold();
146 sink.text( "Classifier" );
147 sink.bold_();
148 sink.tableCell_();
149
150 sink.tableCell();
151 sink.bold();
152 sink.text( "Type" );
153 sink.bold_();
154 sink.tableCell_();
155
156 sink.tableCell();
157 sink.bold();
158 sink.text( "Optional" );
159 sink.bold_();
160 sink.tableCell_();
161
162 sink.tableRow_();
163 while ( iter.hasNext() )
164 {
165 Artifact artifact = (Artifact) iter.next();
166
167 sink.tableRow();
168 sink.tableCell();
169 sink.text( artifact.getGroupId() );
170 sink.tableCell_();
171 sink.tableCell();
172 sink.text( artifact.getArtifactId() );
173 sink.tableCell_();
174 sink.tableCell();
175 sink.text( artifact.getVersion() );
176 sink.tableCell_();
177 sink.tableCell();
178 sink.text( artifact.getScope() );
179 sink.tableCell_();
180 sink.tableCell();
181 sink.text( artifact.getClassifier() );
182 sink.tableCell_();
183 sink.tableCell();
184 sink.text( artifact.getType() );
185 sink.tableCell_();
186 sink.tableCell();
187 if ( artifact.isOptional() )
188 {
189 sink.text( "" );
190 }
191 else
192 {
193 sink.text( "false" );
194 }
195
196 sink.tableCell_();
197 sink.tableRow_();
198 }
199
200 sink.table_();
201 sink.horizontalRule();
202 }
203 }