-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from CycloneDX/bundle
don't fail on dependencies with bundle packaging
- Loading branch information
Showing
3 changed files
with
107 additions
and
3 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
43 changes: 43 additions & 0 deletions
43
src/test/java/org/cyclonedx/maven/BundleDependencyTest.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,43 @@ | ||
package org.cyclonedx.maven; | ||
|
||
import static io.takari.maven.testing.TestResources.assertFilesPresent; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; | ||
import io.takari.maven.testing.executor.MavenVersions; | ||
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; | ||
|
||
/** | ||
* test for https://github.com/CycloneDX/cyclonedx-maven-plugin/issues/272 | ||
* dependency has a bundle packaging which causes Maven's ProjectBuildingException | ||
*/ | ||
@RunWith(MavenJUnitTestRunner.class) | ||
@MavenVersions({"3.6.3"}) | ||
public class BundleDependencyTest extends BaseMavenVerifier { | ||
|
||
public BundleDependencyTest(MavenRuntimeBuilder runtimeBuilder) throws Exception { | ||
super(runtimeBuilder); | ||
} | ||
|
||
@Test | ||
public void testBundleDependencyDebug() throws Exception { | ||
File projDir = resources.getBasedir("bundle"); | ||
|
||
verifier | ||
.forProject(projDir) | ||
.withCliOption("-Dcurrent.version=" + getCurrentVersion()) // inject cyclonedx-maven-plugin version | ||
.withCliOption("-B") | ||
.withCliOption("-X") // debug, will print the full stacktrace with error message if there is any model building issue | ||
.execute("clean", "verify") | ||
.assertErrorFreeLog(); | ||
|
||
String bomContents = fileRead(new File(projDir, "target/bom.json"), true); | ||
assertTrue(bomContents.contains("\"description\" : \"snappy-java: A fast compression/decompression library\"")); | ||
} | ||
} |
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,58 @@ | ||
<?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-272</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0.0</version> | ||
|
||
<name>Issue-272: dependency with bundle packaging cause Maven ProjectBuildingException</name> | ||
|
||
<licenses> | ||
<license> | ||
<name>Apache-2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency><!-- has bundle packaging https://repo.maven.apache.org/maven2/org/xerial/snappy/snappy-java/1.1.8.4/snappy-java-1.1.8.4.pom --> | ||
<groupId>org.xerial.snappy</groupId> | ||
<artifactId>snappy-java</artifactId> | ||
<version>1.1.8.4</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>makeBom</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<outputFormat>json</outputFormat> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |