1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.reporting.exec;
20
21 import org.apache.maven.model.Plugin;
22 import org.apache.maven.reporting.MavenReport;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public class MavenReportExecution {
47 private MavenReport mavenReport;
48
49 private ClassLoader classLoader;
50
51 private Plugin plugin;
52
53 private final String goal;
54
55 public MavenReportExecution(String goal, Plugin plugin, MavenReport mavenReport, ClassLoader classLoader) {
56 this.goal = goal;
57 this.setPlugin(plugin);
58 this.mavenReport = mavenReport;
59 this.classLoader = classLoader;
60 }
61
62 public MavenReportExecution(Plugin plugin, MavenReport mavenReport, ClassLoader classLoader) {
63 this(null, plugin, mavenReport, classLoader);
64 }
65
66 public MavenReportExecution(MavenReport mavenReport) {
67 this(null, null, mavenReport, null);
68 }
69
70
71
72
73
74 public boolean canGenerateReport() {
75 ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
76 try {
77 if (classLoader != null) {
78 Thread.currentThread().setContextClassLoader(classLoader);
79 }
80
81 return mavenReport.canGenerateReport();
82 } finally {
83 if (classLoader != null) {
84 Thread.currentThread().setContextClassLoader(originalClassLoader);
85 }
86 }
87 }
88
89 public MavenReport getMavenReport() {
90 return mavenReport;
91 }
92
93 public void setMavenReport(MavenReport mavenReport) {
94 this.mavenReport = mavenReport;
95 }
96
97 public ClassLoader getClassLoader() {
98 return classLoader;
99 }
100
101 public void setClassLoader(ClassLoader classLoader) {
102 this.classLoader = classLoader;
103 }
104
105 public void setPlugin(Plugin plugin) {
106 this.plugin = plugin;
107 }
108
109 public Plugin getPlugin() {
110 return plugin;
111 }
112
113 public String getGoal() {
114 return goal;
115 }
116 }