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 import org.apache.maven.reporting.MavenReportException;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 public class MavenReportExecution {
48 private final String goal;
49
50 private Plugin plugin;
51
52 private MavenReport mavenReport;
53
54 private ClassLoader classLoader;
55
56 private boolean userDefined;
57
58 public MavenReportExecution(
59 String goal, Plugin plugin, MavenReport mavenReport, ClassLoader classLoader, boolean userDefined) {
60 this.goal = goal;
61 this.setPlugin(plugin);
62 this.mavenReport = mavenReport;
63 this.classLoader = classLoader;
64 this.userDefined = userDefined;
65 }
66
67 public MavenReportExecution(Plugin plugin, MavenReport mavenReport, ClassLoader classLoader, boolean userDefined) {
68 this(null, plugin, mavenReport, classLoader, userDefined);
69 }
70
71 public MavenReportExecution(MavenReport mavenReport) {
72 this(null, null, mavenReport, null, false);
73 }
74
75
76
77
78
79
80 public boolean canGenerateReport() throws MavenReportException {
81 ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
82 try {
83 if (classLoader != null) {
84 Thread.currentThread().setContextClassLoader(classLoader);
85 }
86
87 return mavenReport.canGenerateReport();
88 } finally {
89 if (classLoader != null) {
90 Thread.currentThread().setContextClassLoader(originalClassLoader);
91 }
92 }
93 }
94
95 public MavenReport getMavenReport() {
96 return mavenReport;
97 }
98
99 public void setMavenReport(MavenReport mavenReport) {
100 this.mavenReport = mavenReport;
101 }
102
103 public ClassLoader getClassLoader() {
104 return classLoader;
105 }
106
107 public void setClassLoader(ClassLoader classLoader) {
108 this.classLoader = classLoader;
109 }
110
111 public void setPlugin(Plugin plugin) {
112 this.plugin = plugin;
113 }
114
115 public Plugin getPlugin() {
116 return plugin;
117 }
118
119 public String getGoal() {
120 return goal;
121 }
122
123 public boolean isUserDefined() {
124 return userDefined;
125 }
126
127 public void setUserDefined(boolean userDefined) {
128 this.userDefined = userDefined;
129 }
130 }