-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License information with empty name and url (in pom.xml) are ignored. Signed-off-by: fupgang <75629871+fupgang@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
115 additions
and
2 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,47 @@ | ||
package org.cyclonedx.maven; | ||
|
||
import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; | ||
import io.takari.maven.testing.executor.MavenVersions; | ||
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import static io.takari.maven.testing.TestResources.assertFilesPresent; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
/** | ||
* Test for <a href="https://github.com/CycloneDX/cyclonedx-maven-plugin/issues/382">issue #382</a>: | ||
* Plugin does not gracefully handle present, but empty license data | ||
*/ | ||
@RunWith(MavenJUnitTestRunner.class) | ||
@MavenVersions({"3.6.3"}) | ||
public class Issue382Test extends BaseMavenVerifier { | ||
|
||
public Issue382Test(MavenRuntimeBuilder runtimeBuilder) throws Exception { | ||
super(runtimeBuilder); | ||
} | ||
|
||
@Test | ||
public void test() throws Exception { | ||
File projDir = resources.getBasedir("issue-382"); | ||
|
||
verifier | ||
.forProject(projDir) | ||
.withCliOption("-Dcurrent.version=" + getCurrentVersion()) // inject cyclonedx-maven-plugin version | ||
.withCliOption("-X") // debug | ||
.withCliOption("-B") | ||
.execute("clean", "verify") | ||
.assertErrorFreeLog(); | ||
|
||
assertFileNotContains(projDir, "target/bom.xml", "The BOM does not conform to the CycloneDX BOM standard"); | ||
} | ||
|
||
private static void assertFileNotContains(File basedir, String expectedFile, String expectedContent) throws IOException { | ||
assertFilesPresent(basedir, expectedFile); | ||
String bomContents = fileRead(new File(basedir, expectedFile), true); | ||
assertFalse(String.format("%s contains %s", expectedFile, expectedContent), bomContents.contains(expectedContent)); | ||
} | ||
} |
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 @@ | ||
<?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/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.example</groupId> | ||
<artifactId>issue-382</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0.0</version> | ||
|
||
<name>Issue-64</name> | ||
|
||
<licenses> | ||
<license> | ||
<name/> | ||
<url/> | ||
<distribution/> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> <!-- has empty license information --> | ||
<groupId>com.aliyun</groupId> | ||
<artifactId>aliyun-java-sdk-ram</artifactId> | ||
<version>3.1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.cyclonedx</groupId> | ||
<artifactId>cyclonedx-maven-plugin</artifactId> | ||
<version>${current.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>makeAggregateBom</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<projectType>library</projectType> | ||
<schemaVersion>1.6</schemaVersion> | ||
<includeLicenseText>true</includeLicenseText> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |