Skip to content

Commit

Permalink
rename convert methohds to explicit project vs dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Hervé Boutemy <hboutemy@apache.org>
  • Loading branch information
hboutemy committed Jan 16, 2024
1 parent 051be8e commit 2d130a0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ protected String generatePackageUrl(final Artifact artifact) {
return modelConverter.generatePackageUrl(artifact);
}

protected Component convert(Artifact artifact) {
return modelConverter.convert(artifact, schemaVersion(), includeLicenseText);
protected Component convertMavenDependency(Artifact artifact) {
return modelConverter.convertMavenDependency(artifact, schemaVersion(), includeLicenseText);
}

/**
Expand Down Expand Up @@ -306,7 +306,7 @@ public void execute() throws MojoExecutionException {

String analysis = extractComponentsAndDependencies(topLevelComponents, componentMap, dependencyMap);
if (analysis != null) {
final Metadata metadata = modelConverter.convert(project, projectType, schemaVersion(), includeLicenseText, externalReferences);
final Metadata metadata = modelConverter.convertMavenProject(project, projectType, schemaVersion(), includeLicenseText, externalReferences);

if (schemaVersion().getVersion() >= 1.3) {
metadata.addProperty(newProperty("maven.goal", analysis));
Expand Down Expand Up @@ -486,7 +486,7 @@ protected void populateComponents(final Set<String> topLevelComponents, final Ma
final Component.Scope artifactScope = getComponentScope(artifact, dependencyAnalysis);
final Component component = components.get(purl);
if (component == null) {
final Component newComponent = convert(artifact);
final Component newComponent = convertMavenDependency(artifact);
newComponent.setScope(artifactScope);
components.put(purl, newComponent);
} else if (!topLevelComponents.contains(purl)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected String extractComponentsAndDependencies(final Set<String> topLevelComp
final BomDependencies bomDependencies = extractBOMDependencies(mavenProject);
final Map<String, Dependency> projectDependencies = bomDependencies.getDependencies();

final Component projectBomComponent = convert(mavenProject.getArtifact());
final Component projectBomComponent = convertMavenDependency(mavenProject.getArtifact());
components.put(projectBomComponent.getPurl(), projectBomComponent);
topLevelComponents.add(projectBomComponent.getPurl());

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cyclonedx/maven/CycloneDxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected String extractComponentsAndDependencies(final Set<String> topLevelComp
final BomDependencies bomDependencies = extractBOMDependencies(getProject());
final Map<String, Dependency> projectDependencies = bomDependencies.getDependencies();

final Component projectBomComponent = convert(getProject().getArtifact());
final Component projectBomComponent = convertMavenDependency(getProject().getArtifact());
components.put(projectBomComponent.getPurl(), projectBomComponent);
topLevelComponents.add(projectBomComponent.getPurl());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected String extractComponentsAndDependencies(Set<String> topLevelComponents
final BomDependencies bomDependencies = extractBOMDependencies(mavenProject);
final Map<String, Dependency> projectDependencies = bomDependencies.getDependencies();

final Component projectBomComponent = convert(mavenProject.getArtifact());
final Component projectBomComponent = convertMavenDependency(mavenProject.getArtifact());
components.put(projectBomComponent.getPurl(), projectBomComponent);
topLevelComponents.add(projectBomComponent.getPurl());

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cyclonedx/maven/DefaultModelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private String generatePackageUrl(String groupId, String artifactId, String vers
}

@Override
public Component convert(Artifact artifact, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText) {
public Component convertMavenDependency(Artifact artifact, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText) {
final Component component = new Component();
component.setGroup(artifact.getGroupId());
component.setName(artifact.getArtifactId());
Expand Down Expand Up @@ -339,7 +339,7 @@ else if (licenseChoiceToResolve.getExpression() != null && CycloneDxSchema.Versi
}

@Override
public Metadata convert(final MavenProject project, String projectType, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText, ExternalReference[] externalReferences) {
public Metadata convertMavenProject(final MavenProject project, String projectType, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText, ExternalReference[] externalReferences) {
final Tool tool = new Tool();
final Properties properties = readPluginProperties();
tool.setVendor(properties.getProperty("vendor"));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/cyclonedx/maven/ModelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public interface ModelConverter {
* @param includeLicenseText should license text be included in bom?
* @return a CycloneDX component
*/
Component convert(Artifact artifact, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText);
Component convertMavenDependency(Artifact artifact, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText);

/**
* Converts a MavenProject into a Metadata object.
* Converts a MavenProject into a CycloneDX Metadata object.
*
* @param project the MavenProject to convert
* @param projectType the target CycloneDX component type
Expand All @@ -61,6 +61,6 @@ public interface ModelConverter {
* @param externalReferences the external references
* @return a CycloneDX Metadata object
*/
Metadata convert(MavenProject project, String projectType, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText, ExternalReference[] externalReferences);
Metadata convertMavenProject(MavenProject project, String projectType, CycloneDxSchema.Version schemaVersion, boolean includeLicenseText, ExternalReference[] externalReferences);

}

0 comments on commit 2d130a0

Please sign in to comment.