Skip to content

Commit

Permalink
Generate the latest supported CycloneDX version by default
Browse files Browse the repository at this point in the history
Support all versions supported by the cyclonedx library.

Use 'diff' in the scripted test to get more useful output on failures.

Draft because the serialNumber is not reproducible
  • Loading branch information
raboof committed Oct 19, 2024
1 parent c523478 commit dab19fe
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 34 deletions.
10 changes: 2 additions & 8 deletions src/main/scala/com/github/sbt/sbom/PluginConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ package com.github.sbt.sbom
import org.cyclonedx.Version

object PluginConstants {
val supportedVersions: Seq[Version] = Seq(
Version.VERSION_10,
Version.VERSION_11,
Version.VERSION_12,
Version.VERSION_13,
Version.VERSION_14
)
val defaultSupportedVersion = Version.VERSION_10
val supportedVersions: Seq[Version] = Version.values()
val defaultSupportedVersion: Version = supportedVersions.last
val supportedVersionsDescr: String = {
supportedVersions
.take(supportedVersions.size - 1)
Expand Down
12 changes: 3 additions & 9 deletions src/sbt-test/dependencies/compile/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ lazy val check = taskKey[Unit]("check")
lazy val checkTask = Def.task {
val s: TaskStreams = streams.value
s.log.info("Verifying bom content...")
val bomFile = makeBom.value
val context = thisProject.value
val expected = XML.loadFile(file(s"${context.base}/etc/bom.xml"))
s.log.info(s"${bomFile.getPath}")
val actual = XML.loadFile(bomFile)
val expectedComponents = expected \ "components"
val actualComponents = actual \ "components"
require(expectedComponents == actualComponents, s"${context.id} is failed.")
s.log.info(s"${bomFile.getPath} content verified")
makeBom.value
import scala.sys.process._
require(Seq("diff", "target/bom.xml", s"${thisProject.value.base}/etc/bom.xml").! == 0)
}
16 changes: 15 additions & 1 deletion src/sbt-test/dependencies/compile/etc/bom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom version="1" xmlns="http://cyclonedx.org/schema/bom/1.0">
<bom serialNumber="urn:uuid:110b6432-4928-49c0-962f-d6c6ad2abf3b" version="1" xmlns="http://cyclonedx.org/schema/bom/1.6">
<components>
<component type="library">
<group>org.scala-lang</group>
Expand All @@ -9,6 +9,7 @@
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/org.scala-lang/[email protected]</purl>
Expand All @@ -22,6 +23,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -35,6 +37,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -48,6 +51,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -61,6 +65,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -74,6 +79,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -87,6 +93,7 @@
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<purl>pkg:maven/com.chuusai/[email protected]</purl>
Expand All @@ -100,6 +107,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -113,6 +121,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -126,6 +135,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -139,6 +149,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -152,6 +163,7 @@
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -165,6 +177,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.spire-math/[email protected]</purl>
Expand All @@ -178,6 +191,7 @@
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/org.scala-lang/[email protected]</purl>
Expand Down
10 changes: 3 additions & 7 deletions src/sbt-test/dependencies/integrationTest/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ lazy val checkTask = Def.task {
val s: TaskStreams = streams.value
s.log.info("Verifying bom content...")
val bomFile = (IntegrationTest / makeBom).value
val context = thisProject.value
val expected = XML.loadFile(file(s"${context.base}/etc/bom.xml"))
s.log.info(s"${bomFile.getPath}")
val actual = XML.loadFile(bomFile)
val expectedComponents = expected \ "components"
val actualComponents = actual \ "components"
require(expectedComponents == actualComponents, s"${context.id} is failed.")

import scala.sys.process._
require(Seq("diff", bomFile.getPath, s"${thisProject.value.base}/etc/bom.xml").! == 0)
s.log.info(s"${bomFile.getPath} content verified")
}
28 changes: 28 additions & 0 deletions src/sbt-test/dependencies/integrationTest/etc/bom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/org.scala-lang/[email protected]</purl>
Expand All @@ -22,6 +23,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -35,6 +37,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -48,6 +51,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -61,6 +65,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -74,6 +79,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -87,6 +93,7 @@
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<purl>pkg:maven/com.chuusai/[email protected]</purl>
Expand All @@ -100,6 +107,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -113,6 +121,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -126,6 +135,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -139,6 +149,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -152,6 +163,7 @@
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -165,6 +177,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.spire-math/[email protected]</purl>
Expand All @@ -178,6 +191,7 @@
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/org.scala-lang/[email protected]</purl>
Expand All @@ -191,6 +205,7 @@
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/org.scala-lang/[email protected]</purl>
Expand All @@ -204,6 +219,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -217,6 +233,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -230,6 +247,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -243,6 +261,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -256,6 +275,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -269,6 +289,7 @@
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<purl>pkg:maven/com.chuusai/[email protected]</purl>
Expand All @@ -282,6 +303,7 @@
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/io.circe/[email protected]</purl>
Expand All @@ -295,6 +317,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -308,6 +331,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -321,6 +345,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -334,6 +359,7 @@
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<purl>pkg:maven/org.typelevel/[email protected]</purl>
Expand All @@ -347,6 +373,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
</license>
</licenses>
<purl>pkg:maven/org.spire-math/[email protected]</purl>
Expand All @@ -360,6 +387,7 @@
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<purl>pkg:maven/org.scala-lang/[email protected]</purl>
Expand Down
Loading

0 comments on commit dab19fe

Please sign in to comment.