Skip to content

Commit

Permalink
Merge pull request #489 from CycloneDX/fix-properties-resolution
Browse files Browse the repository at this point in the history
fix: check that plugin.properties file exists
  • Loading branch information
skhokhlov authored Aug 9, 2024
2 parents 66144a6 + 3cd522b commit 6734c08
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/org/cyclonedx/gradle/CycloneDxTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -564,8 +565,12 @@ protected Metadata createMetadata() {

private Properties readPluginProperties() {
final Properties props = new Properties();
try {
props.load(this.getClass().getResourceAsStream("plugin.properties"));
try (InputStream inputStream = this.getClass().getResourceAsStream("plugin.properties")) {
if (inputStream == null) {
getLogger().warn("Failed to locate plugin.properties");
} else {
props.load(inputStream);
}
} catch (NullPointerException | IOException e) {
getLogger().warn("Unable to load plugin.properties", e);
}
Expand Down

0 comments on commit 6734c08

Please sign in to comment.