-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christopher Josey <[email protected]>
- Loading branch information
Showing
8 changed files
with
194 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.spdx.it</groupId> | ||
<artifactId>simple-aggregate-it</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<description>A simple IT verifying the basic use case.</description> | ||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.release>11</maven.compiler.release> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>commons-collections</groupId> | ||
<artifactId>commons-collections</artifactId> | ||
<version>3.2.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<modules> | ||
<module>../advanced</module> | ||
</modules> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>build-spdx</id> | ||
<goals> | ||
<goal>aggregateSPDX</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.11.0</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
24 changes: 24 additions & 0 deletions
24
src/it/simple-aggregate-it/src/main/java/simple/Simple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2014 Source Auditor Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package simple; | ||
|
||
public class Simple | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
System.out.println( "Hello World!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2014 Source Auditor Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package simple; | ||
|
||
import org.junit.Test; | ||
|
||
public class SimpleTest | ||
{ | ||
@Test | ||
public void test() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
File spdxFile = new File( basedir, "target/site/org.spdx.it_simple-aggregate-it-1.0-SNAPSHOT.spdx.json" ); | ||
|
||
assert spdxFile.isFile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.spdx.maven; | ||
|
||
import org.apache.maven.plugins.annotations.LifecyclePhase; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.project.DefaultProjectBuildingRequest; | ||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.project.ProjectBuildingRequest; | ||
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; | ||
import org.apache.maven.shared.dependency.graph.DependencyNode; | ||
|
||
import org.spdx.core.InvalidSPDXAnalysisException; | ||
import org.spdx.maven.utils.AbstractDependencyBuilder; | ||
import org.spdx.maven.utils.AbstractDocumentBuilder; | ||
import org.spdx.maven.utils.LicenseMapperException; | ||
import org.spdx.maven.utils.SpdxV2DependencyBuilder; | ||
import org.spdx.maven.utils.SpdxV2DocumentBuilder; | ||
import org.spdx.maven.utils.SpdxV3DependencyBuilder; | ||
import org.spdx.maven.utils.SpdxV3DocumentBuilder; | ||
|
||
|
||
import java.util.List; | ||
import java.util.Arrays; | ||
|
||
@Mojo( name = "aggregateSPDX", | ||
defaultPhase = LifecyclePhase.VERIFY, | ||
requiresOnline = true, | ||
threadSafe = true ) | ||
public class AggregateSpdxMojo extends CreateSpdxMojo { | ||
|
||
@Override | ||
protected void buildSpdxDependencyInformation( AbstractDocumentBuilder builder, OutputFormat outputFormatEnum ) | ||
throws DependencyGraphBuilderException, LicenseMapperException, InvalidSPDXAnalysisException { | ||
AbstractDependencyBuilder dependencyBuilder; | ||
if ( builder instanceof SpdxV3DocumentBuilder) | ||
{ | ||
dependencyBuilder = new SpdxV3DependencyBuilder( ( SpdxV3DocumentBuilder ) builder, createExternalRefs, | ||
generatePurls, useArtifactID, includeTransitiveDependencies ); | ||
} | ||
else | ||
{ | ||
dependencyBuilder = new SpdxV2DependencyBuilder( ( SpdxV2DocumentBuilder ) builder, createExternalRefs, | ||
generatePurls, useArtifactID, includeTransitiveDependencies ); | ||
} | ||
if ( session != null ) | ||
{ | ||
List<MavenProject> projects = session.getAllProjects(); //includes the current project | ||
if ( !projects.isEmpty() ) | ||
{ | ||
getLog().info( "List of projects that will be aggregated into one file: " | ||
+ Arrays.toString( projects.toArray() ) ); | ||
for ( MavenProject project : projects ) | ||
{ | ||
ProjectBuildingRequest request = new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() ); | ||
request.setProject( project ); | ||
DependencyNode parentNode = dependencyGraphBuilder.buildDependencyGraph( request, null ); | ||
dependencyBuilder.addMavenDependencies( mavenProjectBuilder, session, project, parentNode, builder.getProjectPackage() ); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters