Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
eygraber committed Aug 29, 2023
1 parent 1a97720 commit 8582c80
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/spdx/sbom/gradle/maven/PomInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.net.URI;
import java.util.List;
import java.util.Optional;

import org.apache.maven.model.Organization;
import org.immutables.serial.Serial;
import org.immutables.value.Value.Immutable;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/spdx/sbom/gradle/maven/PomResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ public Map<String, PomInfo> effectivePoms(Configuration pomsConfig) {
ImmutableDeveloperInfo.builder()
.name(Optional.ofNullable(d.getName()))
.email(Optional.ofNullable(d.getEmail()))
.build()
)
.collect(Collectors.toList())
)
.build())
.collect(Collectors.toList()))
.build());
}
return effectivePoms;
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/org/spdx/sbom/gradle/utils/SpdxDocumentBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.annotation.Nullable;

import org.gradle.api.artifacts.ModuleVersionIdentifier;
import org.gradle.api.artifacts.component.ComponentArtifactIdentifier;
import org.gradle.api.artifacts.component.ComponentIdentifier;
Expand Down Expand Up @@ -353,9 +351,7 @@ private Optional<SpdxPackage> createMavenModulePackage(

spdxPkgBuilder.setVersionInfo(moduleId.getVersion());

spdxPkgBuilder.setSupplier(
buildMavenPackageSupplier(pomInfo)
);
spdxPkgBuilder.setSupplier(buildMavenPackageSupplier(pomInfo));

String sha1 =
com.google.common.io.Files.asByteSource(dependencyFile).hash(Hashing.sha1()).toString();
Expand All @@ -372,17 +368,21 @@ private Optional<SpdxPackage> createMavenModulePackage(
}

private String buildMavenPackageSupplier(PomInfo pomInfo) {
var organizationName = pomInfo.getOrganization().flatMap(o ->
Optional.ofNullable(o.getName())).map(n ->
"Organization: " + n);

var developer = pomInfo.getDevelopers().stream().filter(d -> d.getName().isPresent()).findFirst();
Optional<String> developerName = Stream.of(
developer.flatMap(d -> d.getName().map(name -> "Person: " + name)),
developer.flatMap(d -> d.getEmail().map(email -> " (" + email + ")"))
).filter(Optional::isPresent)
.map(Optional::get)
.reduce((name, email) -> name + email);
var organizationName =
pomInfo
.getOrganization()
.flatMap(o -> Optional.ofNullable(o.getName()))
.map(n -> "Organization: " + n);

var developer =
pomInfo.getDevelopers().stream().filter(d -> d.getName().isPresent()).findFirst();
Optional<String> developerName =
Stream.of(
developer.flatMap(d -> d.getName().map(name -> "Person: " + name)),
developer.flatMap(d -> d.getEmail().map(email -> " (" + email + ")")))
.filter(Optional::isPresent)
.map(Optional::get)
.reduce((name, email) -> name + email);

return organizationName.orElseGet(() -> developerName.orElse("Organization: NOASSERTION"));
}
Expand Down

0 comments on commit 8582c80

Please sign in to comment.