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