1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.report.projectinfo;
20
21 import java.util.Locale;
22
23 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
24 import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
25 import org.apache.maven.plugins.annotations.Component;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.ResolutionScope;
28 import org.apache.maven.project.DefaultProjectBuildingRequest;
29 import org.apache.maven.project.ProjectBuildingRequest;
30 import org.apache.maven.report.projectinfo.dependencies.ManagementDependencies;
31 import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils;
32 import org.apache.maven.report.projectinfo.dependencies.renderer.DependencyManagementRenderer;
33 import org.apache.maven.reporting.MavenReportException;
34
35
36
37
38
39
40
41 @Mojo(name = "dependency-management", requiresDependencyResolution = ResolutionScope.TEST)
42 public class DependencyManagementReport extends AbstractProjectInfoReport {
43
44
45
46
47
48
49
50
51
52 @Component
53 protected ArtifactMetadataSource artifactMetadataSource;
54
55
56
57
58
59
60 @Component
61 private RepositoryMetadataManager repositoryMetadataManager;
62
63
64
65
66
67
68
69
70 private ManagementDependencies managementDependencies;
71
72
73
74
75
76 @Override
77 public boolean canGenerateReport() throws MavenReportException {
78 boolean result = super.canGenerateReport();
79 if (result && skipEmptyReport) {
80 result = getManagementDependencies().hasDependencies();
81 }
82
83 return result;
84 }
85
86 @Override
87 public void executeReport(Locale locale) {
88 ProjectBuildingRequest buildingRequest =
89 new DefaultProjectBuildingRequest(getSession().getProjectBuildingRequest());
90 buildingRequest.setLocalRepository(localRepository);
91 buildingRequest.setRemoteRepositories(remoteRepositories);
92 buildingRequest.setPluginArtifactRepositories(pluginRepositories);
93 buildingRequest.setProcessPlugins(false);
94
95 RepositoryUtils repoUtils = new RepositoryUtils(
96 getLog(),
97 projectBuilder,
98 repositorySystem,
99 resolver,
100 remoteRepositories,
101 pluginRepositories,
102 buildingRequest,
103 repositoryMetadataManager);
104
105 DependencyManagementRenderer r = new DependencyManagementRenderer(
106 getSink(),
107 locale,
108 getI18N(locale),
109 getLog(),
110 getManagementDependencies(),
111 artifactMetadataSource,
112 repositorySystem,
113 projectBuilder,
114 buildingRequest,
115 repoUtils,
116 getLicenseMappings());
117 r.render();
118 }
119
120
121
122
123 public String getOutputName() {
124 return "dependency-management";
125 }
126
127 @Override
128 protected String getI18Nsection() {
129 return "dependency-management";
130 }
131
132
133
134
135
136 private ManagementDependencies getManagementDependencies() {
137 if (managementDependencies != null) {
138 return managementDependencies;
139 }
140
141 if (project.getDependencyManagement() == null) {
142 managementDependencies = new ManagementDependencies(null);
143 } else {
144 managementDependencies =
145 new ManagementDependencies(project.getDependencyManagement().getDependencies());
146 }
147
148 return managementDependencies;
149 }
150 }