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

Support metadata when dependency is any other dependency type than jar #431

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
32 changes: 10 additions & 22 deletions src/main/java/org/cyclonedx/maven/DefaultModelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,16 @@ public Component convert(Artifact artifact, CycloneDxSchema.Version schemaVersio
if (CycloneDxSchema.Version.VERSION_10 != schemaVersion) {
component.setBomRef(component.getPurl());
}
if (isDescribedArtifact(artifact)) {
try {
final MavenProject project = getEffectiveMavenProject(artifact);
if (project != null) {
extractComponentMetadata(project, component, schemaVersion, includeLicenseText);
}
} catch (ProjectBuildingException e) {
if (logger.isDebugEnabled()) {
logger.warn("Unable to create Maven project for " + artifact.getId() + " from repository.", e);
} else {
logger.warn("Unable to create Maven project for " + artifact.getId() + " from repository.");
}
try {
final MavenProject project = getEffectiveMavenProject(artifact);
if (project != null) {
extractComponentMetadata(project, component, schemaVersion, includeLicenseText);
}
} catch (ProjectBuildingException e) {
if (logger.isDebugEnabled()) {
logger.warn("Unable to create Maven project for " + artifact.getId() + " from repository.", e);
} else {
logger.warn("Unable to create Maven project for " + artifact.getId() + " from repository.");
}
}
return component;
Expand All @@ -194,16 +192,6 @@ private boolean isModified(Artifact artifact) {
return false;
}

/**
* Returns true for any artifact type which will positively have a POM that
* describes the artifact.
* @param artifact the artifact
* @return true if artifact will have a POM, false if not
*/
private boolean isDescribedArtifact(Artifact artifact) {
return artifact.getType().equalsIgnoreCase("jar");
}

/**
* Extracts data from a project and adds the data to the component.
* @param project the project to extract data from
Expand Down