From 3193789a116b807b079498f527d33ea242566bc8 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 15 Sep 2023 21:17:52 +0200 Subject: [PATCH 1/3] Use frontend-maven-plugin configuration of parent POM. --- .mvn_exec_node | 0 package.json | 4 +++- pom.xml | 29 +---------------------------- release.sh | 5 +++++ 4 files changed, 9 insertions(+), 29 deletions(-) create mode 100644 .mvn_exec_node create mode 100755 release.sh diff --git a/.mvn_exec_node b/.mvn_exec_node new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json index 6c551aa..1f02bbc 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ "remark-preset-lint-recommended": "6.1.3" }, "scripts": { - "lint-md": "remark ." + "lint-md": "remark .", + "mvnbuild": "", + "mvntest": "" }, "remarkConfig": { "plugins": [ diff --git a/pom.xml b/pom.xml index a2fd917..ceb62fc 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jvnet.hudson.plugins analysis-pom - 6.10.0 + 6.12.0 @@ -119,33 +119,6 @@ - - com.github.eirslett - frontend-maven-plugin - 1.13.4 - - - install node and npm - - install-node-and-npm - - generate-resources - - v18.12.0 - - - - npm install - - npm - - generate-resources - - install - - - - org.apache.maven.plugins maven-resources-plugin diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..a6af542 --- /dev/null +++ b/release.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +git pull +git push +mvn -B clean release:prepare release:perform From 70bece637c59d6b6dbc4f6eedad36d8dc2da399e Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 15 Sep 2023 21:45:28 +0200 Subject: [PATCH 2/3] Fix outstanding SpotBugs warnings. --- .../plugins/fontawesome/FontAwesomeIcons.java | 65 ++++++++++++------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java b/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java index 2ed7803..9816dd0 100644 --- a/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java +++ b/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java @@ -1,25 +1,36 @@ package io.jenkins.plugins.fontawesome; -import edu.umd.cs.findbugs.annotations.CheckForNull; -import org.apache.commons.lang3.StringUtils; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.nio.file.*; -import java.util.*; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.Enumeration; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; + +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +import io.jenkins.plugins.fontawesome.SvgTag.FontAwesomeStyle; + /** * Utility to work with icons provided by the font-awesome-api-plugin. * * @author strangelookingnerd */ public final class FontAwesomeIcons { - private static final Logger LOGGER = Logger.getLogger(FontAwesomeIcons.class.getName()); private static final String SVG_FILE_ENDING = ".svg"; private static final String IMAGES_SYMBOLS_PATH = "images/symbols/"; @@ -29,7 +40,9 @@ public final class FontAwesomeIcons { /** * Takes an icon name and generates an icon class name from it. * - * @param icon the icon name + * @param icon + * the icon name + * * @return the icon class name */ public static String getIconClassName(final String icon) { @@ -39,8 +52,7 @@ public static String getIconClassName(final String icon) { /** * Get all available icons provided by the font-awesome-api-plugin. * - * @return a sorted map of available icons with icon name as key and the icon - * class name as value. + * @return a sorted map of available icons with icon name as key and the icon class name as value. */ public static Map getAvailableIcons() { return getAvailableIcons(null); @@ -49,15 +61,17 @@ public static Map getAvailableIcons() { /** * Get all available icons provided by the font-awesome-api-plugin filtered by their style. * - * @param filter the style to filter - * @return a sorted map of available icons with icon name as key and the icon - * class name as value filtered by the given style. + * @param filter + * the style to filter + * + * @return a sorted map of available icons with icon name as key and the icon class name as value filtered by the + * given style. */ - public static Map getAvailableIcons(final SvgTag.FontAwesomeStyle filter) { + public static Map getAvailableIcons(@CheckForNull final FontAwesomeStyle filter) { return getIconsFromClasspath(filter); } - private static Map getIconsFromClasspath(final SvgTag.FontAwesomeStyle filter) { + private static Map getIconsFromClasspath(@CheckForNull final FontAwesomeStyle filter) { try { Enumeration urls = FontAwesomeIcons.class.getClassLoader().getResources(IMAGES_SYMBOLS_PATH); @@ -85,18 +99,24 @@ private static Map getIconsFromClasspath(final SvgTag.FontAwesom return new LinkedHashMap<>(); } - private static Map collectIcons(final Path path, @CheckForNull final SvgTag.FontAwesomeStyle filter) throws IOException { + @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") + private static Map collectIcons(final Path path, @CheckForNull final FontAwesomeStyle filter) + throws IOException { Map icons = new LinkedHashMap<>(); if (path != null) { - try (Stream stream = filter == null ? Files.walk(path, 2) : Files.walk(path.resolve(filter.name().toLowerCase(Locale.ENGLISH)), 1)) { - stream.filter(icon -> icon != null && icon.getFileName() != null && StringUtils.endsWith(icon.getFileName().toString(), SVG_FILE_ENDING)) + try (Stream stream = filter == null ? Files.walk(path, 2) : Files.walk( + path.resolve(filter.name().toLowerCase(Locale.ENGLISH)), 1)) { + stream.filter(icon -> icon != null && icon.getFileName() != null && StringUtils.endsWith( + icon.getFileName().toString(), SVG_FILE_ENDING)) .sorted().forEach(icon -> { - if (icon.getParent() != null && icon.getParent().getFileName() != null && icon.getFileName() != null) { - String iconName = icon.getParent().getFileName() + "/" + StringUtils.removeEnd(icon.getFileName().toString(), SVG_FILE_ENDING); - icons.put(iconName, getIconClassName(iconName)); - } - } + if (icon.getParent() != null && icon.getParent().getFileName() != null + && icon.getFileName() != null) { + String iconName = icon.getParent().getFileName() + "/" + StringUtils.removeEnd( + icon.getFileName().toString(), SVG_FILE_ENDING); + icons.put(iconName, getIconClassName(iconName)); + } + } ); } } @@ -107,5 +127,4 @@ private static Map collectIcons(final Path path, @CheckForNull private FontAwesomeIcons() { // hidden } - } From 1778685290df6579b722e4e103b67211f76f521f Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 15 Sep 2023 21:49:04 +0200 Subject: [PATCH 3/3] Make code more readable. --- .../plugins/fontawesome/FontAwesomeIcons.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java b/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java index 9816dd0..997d5a6 100644 --- a/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java +++ b/src/main/java/io/jenkins/plugins/fontawesome/FontAwesomeIcons.java @@ -100,13 +100,12 @@ private static Map getIconsFromClasspath(@CheckForNull final Fon } @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") - private static Map collectIcons(final Path path, @CheckForNull final FontAwesomeStyle filter) - throws IOException { + private static Map collectIcons( + @CheckForNull final Path path, @CheckForNull final FontAwesomeStyle filter) throws IOException { Map icons = new LinkedHashMap<>(); if (path != null) { - try (Stream stream = filter == null ? Files.walk(path, 2) : Files.walk( - path.resolve(filter.name().toLowerCase(Locale.ENGLISH)), 1)) { + try (Stream stream = findIcons(path, filter)) { stream.filter(icon -> icon != null && icon.getFileName() != null && StringUtils.endsWith( icon.getFileName().toString(), SVG_FILE_ENDING)) .sorted().forEach(icon -> { @@ -124,6 +123,14 @@ private static Map collectIcons(final Path path, @CheckForNull f return icons; } + private static Stream findIcons(final Path path, @CheckForNull final FontAwesomeStyle filter) throws IOException { + if (filter == null) { + return Files.walk(path, 2); + } + + return Files.walk(path.resolve(filter.name().toLowerCase(Locale.ENGLISH)), 1); + } + private FontAwesomeIcons() { // hidden }