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

Include transitive dependencies in SBOM output #63

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
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
22 changes: 14 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.version>3.8.5</maven.version>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>spdx</sonar.organization>
<sonar.projectKey>spdx-maven-plugin</sonar.projectKey>
Expand Down Expand Up @@ -56,12 +57,12 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.2.1</version>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.3</version>
<version>3.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -87,13 +88,13 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.1</version>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -104,12 +105,17 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>file-management</artifactId>
<version>1.2.1</version>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.2.1</version>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${maven.version}</version>
</dependency>
</dependencies>

Expand Down
17 changes: 5 additions & 12 deletions src/main/java/org/spdx/maven/CreateSpdxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.apache.maven.shared.model.fileset.FileSet;
Expand All @@ -41,14 +42,13 @@
import org.spdx.library.model.license.LicenseInfoFactory;
import org.spdx.library.model.license.SpdxNoAssertionLicense;

import edu.emory.mathcs.backport.java.util.Arrays;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -78,7 +78,8 @@
* Additional SPDX fields are supplied as configuration parameters to this plugin.
*/
@Mojo( name = "createSPDX",
defaultPhase = LifecyclePhase.VERIFY )
defaultPhase = LifecyclePhase.VERIFY,
requiresDependencyResolution = ResolutionScope.COMPILE )
@Execute( goal = "createSPDX",
phase = LifecyclePhase.VERIFY )
public class CreateSpdxMojo extends AbstractMojo
Expand Down Expand Up @@ -360,10 +361,9 @@ public class CreateSpdxMojo extends AbstractMojo

private String artifactType;

@SuppressWarnings( "unchecked" )
public void execute() throws MojoExecutionException
{
this.dependencies = mavenProject.getDependencyArtifacts();
this.dependencies = mavenProject.getArtifacts();
if ( this.getLog() == null )
{
throw ( new MojoExecutionException( "Null log for Mojo" ) );
Expand Down Expand Up @@ -694,7 +694,6 @@ private void logIncludedDirectories( FileSet[] includedDirectories )
for ( FileSet includedDirectory : includedDirectories )
{
StringBuilder sb = new StringBuilder( "Included Directory: " + includedDirectory.getDirectory() );
@SuppressWarnings( "unchecked" )
List<String> includes = includedDirectory.getIncludes();
if ( includes != null && includes.size() > 0 )
{
Expand All @@ -706,7 +705,6 @@ private void logIncludedDirectories( FileSet[] includedDirectories )
sb.append( includes.get( j ) );
}
}
@SuppressWarnings( "unchecked" )
List<String> excludes = includedDirectory.getExcludes();
if ( excludes != null && excludes.size() > 0 )
{
Expand Down Expand Up @@ -809,7 +807,6 @@ private SpdxProjectInformation getSpdxProjectInfoFromParameters( LicenseManager
AnyLicenseInfo declaredLicense = null;
if ( this.licenseDeclared == null )
{
@SuppressWarnings( "unchecked" )
List<License> mavenLicenses = mavenProject.getLicenses();
try
{
Expand Down Expand Up @@ -998,7 +995,6 @@ private String getDefaultProjectName()
private FileSet[] getSourceDirectories()
{
ArrayList<FileSet> result = new ArrayList<>();
@SuppressWarnings( "unchecked" )
List<String> sourceRoots = this.mavenProject.getCompileSourceRoots();
if ( sourceRoots != null )
{
Expand All @@ -1024,7 +1020,6 @@ private FileSet[] getSourceDirectories()
private FileSet[] getResourceDirectories()
{
ArrayList<FileSet> result = new ArrayList<>();
@SuppressWarnings( "unchecked" )
List<String> sourceRoots = this.mavenProject.getCompileSourceRoots();
if ( sourceRoots != null )
{
Expand All @@ -1038,7 +1033,6 @@ private FileSet[] getResourceDirectories()
this.getLog().debug( "Adding sourceRoot directory " + srcFileSet.getDirectory() );
}
}
@SuppressWarnings( "unchecked" )
List<Resource> resourceList = this.mavenProject.getResources();
if ( resourceList != null )
{
Expand Down Expand Up @@ -1066,7 +1060,6 @@ private FileSet[] getResourceDirectories()
private FileSet[] getTestDirectories()
{
ArrayList<FileSet> result = new ArrayList<>();
@SuppressWarnings( "unchecked" )
List<String> sourceRoots = this.mavenProject.getTestCompileSourceRoots();
if ( sourceRoots != null )
{
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/spdx/maven/TestSpdxFileCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -43,8 +44,6 @@
import org.spdx.library.model.pointer.StartEndPointer;
import org.spdx.storage.simple.InMemSpdxStore;

import edu.emory.mathcs.backport.java.util.Collections;


public class TestSpdxFileCollector
{
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/spdx/maven/TestSpdxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.apache.maven.plugin.testing.AbstractMojoTestCase;
Expand Down Expand Up @@ -34,8 +35,6 @@
import org.spdx.storage.ISerializableModelStore;
import org.spdx.storage.simple.InMemSpdxStore;

import edu.emory.mathcs.backport.java.util.Collections;

public class TestSpdxMojo extends AbstractMojoTestCase
{

Expand Down