Skip to content

Commit f828e76

Browse files
authored
Make dep on matrix-project optional (#287)
1 parent 807f0ff commit f828e76

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<dependency>
6464
<groupId>org.jenkins-ci.plugins</groupId>
6565
<artifactId>matrix-project</artifactId>
66+
<optional>true</optional>
6667
</dependency>
6768
<dependency>
6869
<groupId>org.jenkins-ci.plugins.workflow</groupId>

src/main/java/htmlpublisher/HtmlPublisher.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,21 +390,26 @@ public Collection<? extends Action> getProjectActions(AbstractProject<?, ?> proj
390390
List<Action> actions = new ArrayList<>();
391391
for (HtmlPublisherTarget target : this.reportTargets) {
392392
actions.add(target.getProjectAction(project));
393-
if (project instanceof MatrixProject && ((MatrixProject) project).getActiveConfigurations() != null){
394-
for (MatrixConfiguration mc : ((MatrixProject) project).getActiveConfigurations()){
395-
try {
396-
mc.onLoad(mc.getParent(), mc.getName());
397-
}
398-
catch (IOException e){
399-
//Could not reload the configuration.
400-
}
401-
}
393+
if (project.getClass().getName().equals("hudson.matrix.MatrixProject")) {
394+
adjustMatrixProject(project);
402395
}
403396
}
404397
return actions;
405398
}
406399
}
407400

401+
private static void adjustMatrixProject(AbstractProject<?, ?> project) {
402+
MatrixProject mp = (MatrixProject) project;
403+
if (mp.getActiveConfigurations() != null) {
404+
for (MatrixConfiguration mc : mp.getActiveConfigurations()) {
405+
try {
406+
mc.onLoad(mc.getParent(), mc.getName());
407+
} catch (IOException e) {
408+
//Could not reload the configuration.
409+
}
410+
}
411+
}
412+
}
408413

409414
@SuppressRestrictedWarnings(NoExternalUse.class)
410415
public static DirScanner dirScannerGlob(String includes, String excludes, boolean useDefaultExcludes, OpenOption... openOptions) throws Exception {

0 commit comments

Comments
 (0)