Skip to content

Commit

Permalink
fix: CycloneDx schema version to support 1.4 (#153)
Browse files Browse the repository at this point in the history
Signed-off-by: K3rnelPan1c <69395733+k3rnelpan1c-dev@users.noreply.github.com>
  • Loading branch information
k3rnelpan1c-dev committed May 29, 2022
1 parent e0d09d8 commit 3dc3e31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ cyclonedxBom {

If you are using the Kotlin DSL, the plugin can be configured as following:

```
```kotlin
tasks.cyclonedxBom {
setIncludeConfigs(["runtimeClasspath"])
setSkipConfigs(["compileClasspath", "testCompileClasspath"])
setIncludeConfigs(listOf("runtimeClasspath"))
setSkipConfigs(listOf("compileClasspath", "testCompileClasspath"))
setProjectType("application")
setSchemaVersion("1.4")
setDestination(project.file("build/reports"))
setOutputName("bom")
setincludeBomSerialNumber(false)
}
```

Run gradle with info logging (-i option) to see which configurations add to the BOM.
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/org/cyclonedx/gradle/CycloneDxTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class CycloneDxTask extends DefaultTask {
public CycloneDxTask() {
this.outputName = "bom";
this.destination = new File(getProject().getBuildDir(), "reports");
this.schemaVersion = CycloneDxSchema.Version.VERSION_13.getVersionString();
this.schemaVersion = CycloneDxSchema.Version.VERSION_14.getVersionString();
this.projectType = DEFAULT_PROJECT_TYPE;
this.includeBomSerialNumber = true;
}
Expand Down Expand Up @@ -486,15 +486,13 @@ private void writeJSONBom(final CycloneDxSchema.Version schemaVersion, final Bom
* @return the CycloneDX schema to use
*/
private CycloneDxSchema.Version schemaVersion() {
final String version = getSchemaVersion();
if ("1.0".equals(version)) {
return CycloneDxSchema.Version.VERSION_10;
} else if ("1.1".equals(version)) {
return CycloneDxSchema.Version.VERSION_11;
} else if ("1.2".equals(version)) {
return CycloneDxSchema.Version.VERSION_12;
switch (getSchemaVersion()) {
case "1.0": return CycloneDxSchema.Version.VERSION_10;
case "1.1": return CycloneDxSchema.Version.VERSION_11;
case "1.2": return CycloneDxSchema.Version.VERSION_12;
case "1.3": return CycloneDxSchema.Version.VERSION_13;
default: return CycloneDxSchema.Version.VERSION_14;
}
return CycloneDxSchema.Version.VERSION_13;
}

private boolean getBooleanParameter(String parameter, boolean defaultValue) {
Expand Down

0 comments on commit 3dc3e31

Please sign in to comment.