From f828e76b0c15acfefeb1e032c879730095f5caca Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 15 Jul 2024 21:23:25 -0400 Subject: [PATCH] Make dep on `matrix-project` optional (#287) --- pom.xml | 1 + .../java/htmlpublisher/HtmlPublisher.java | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 8345849..5bc828f 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,7 @@ org.jenkins-ci.plugins matrix-project + true org.jenkins-ci.plugins.workflow diff --git a/src/main/java/htmlpublisher/HtmlPublisher.java b/src/main/java/htmlpublisher/HtmlPublisher.java index 8245f0b..396f7bb 100644 --- a/src/main/java/htmlpublisher/HtmlPublisher.java +++ b/src/main/java/htmlpublisher/HtmlPublisher.java @@ -390,21 +390,26 @@ public Collection getProjectActions(AbstractProject proj List actions = new ArrayList<>(); for (HtmlPublisherTarget target : this.reportTargets) { actions.add(target.getProjectAction(project)); - if (project instanceof MatrixProject && ((MatrixProject) project).getActiveConfigurations() != null){ - for (MatrixConfiguration mc : ((MatrixProject) project).getActiveConfigurations()){ - try { - mc.onLoad(mc.getParent(), mc.getName()); - } - catch (IOException e){ - //Could not reload the configuration. - } - } + if (project.getClass().getName().equals("hudson.matrix.MatrixProject")) { + adjustMatrixProject(project); } } return actions; } } + private static void adjustMatrixProject(AbstractProject project) { + MatrixProject mp = (MatrixProject) project; + if (mp.getActiveConfigurations() != null) { + for (MatrixConfiguration mc : mp.getActiveConfigurations()) { + try { + mc.onLoad(mc.getParent(), mc.getName()); + } catch (IOException e) { + //Could not reload the configuration. + } + } + } + } @SuppressRestrictedWarnings(NoExternalUse.class) public static DirScanner dirScannerGlob(String includes, String excludes, boolean useDefaultExcludes, OpenOption... openOptions) throws Exception {