Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NullPointerException when no <versioning> tag is present in maven… #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.jboss.logging.Logger;
import org.wildfly.channel.ChannelManifest;
import org.wildfly.channel.ChannelManifestMapper;
import org.wildfly.channel.Stream;
Expand All @@ -20,6 +21,8 @@
description = "Scans a local maven repository and creates a manifest file representing the GAVs existing in the repository.")
public class CreateManifestFromRepoCommand implements Callable<Integer> {

protected static final Logger logger = Logger.getLogger(CreateManifestFromRepoCommand.class);

private static final String MAVEN_METADATA_XML = "maven-metadata.xml";

@CommandLine.Parameters(index = "0",
Expand Down Expand Up @@ -47,8 +50,12 @@ public Integer call() throws Exception {
// Skip metadata files that list specific artifact files, we are just interested in versions.
continue;
}
for (String version : metadata.getVersioning().getVersions()) {
streams.add(new Stream(metadata.getGroupId(), metadata.getArtifactId(), version));
if (metadata.getVersioning() != null) {
for (String version : metadata.getVersioning().getVersions()) {
streams.add(new Stream(metadata.getGroupId(), metadata.getArtifactId(), version));
}
} else {
logger.warn("No <versioning> tag in " + MAVEN_METADATA_XML + " file " + metadataFile.toFile().getAbsolutePath());
}
}
}
Expand Down