CycloneDX Gradle 插件使用教程

CycloneDX Gradle 插件使用教程

cyclonedx-gradle-pluginCreates CycloneDX Software Bill of Materials (SBOM) from Gradle projects项目地址:https://gitcode.com/gh_mirrors/cy/cyclonedx-gradle-plugin

1. 项目的目录结构及介绍

CycloneDX Gradle 插件的 GitHub 仓库目录结构如下:

cyclonedx-gradle-plugin/
├── src/
│   ├── main/
│   │   ├── groovy/
│   │   └── resources/
│   └── test/
│       ├── groovy/
│       └── resources/
├── build.gradle
├── gradle.properties
├── settings.gradle
├── LICENSE
├── README.md
└── ...
  • src/main/groovy/:包含插件的主要实现代码。
  • src/main/resources/:包含插件的资源文件。
  • src/test/groovy/:包含插件的测试代码。
  • src/test/resources/:包含测试资源文件。
  • build.gradle:Gradle 构建脚本。
  • gradle.properties:Gradle 属性配置文件。
  • settings.gradle:Gradle 项目设置文件。
  • LICENSE:项目许可证文件。
  • README.md:项目说明文档。

2. 项目的启动文件介绍

CycloneDX Gradle 插件的启动文件主要是 build.gradlesettings.gradle

build.gradle

这是主要的构建脚本文件,包含插件的依赖、任务定义和其他配置。

plugins {
    id 'org.cyclonedx.bom' version '1.10.0'
}

repositories {
    mavenCentral()
}

dependencies {
    // 依赖项定义
}

cyclonedxBom {
    includeConfigs = ["runtimeClasspath"]
    skipConfigs = ["compileClasspath", "testCompileClasspath"]
    projectType = "application"
    schemaVersion = "1.6"
    destination = file("build/reports")
    outputName = "bom"
    outputFormat = "json"
    includeBomSerialNumber = false
    includeLicenseText = true
    componentVersion = "2.0.0"
    componentName = "my-component"
}

settings.gradle

这是项目设置文件,定义了项目的名称和子项目。

rootProject.name = 'cyclonedx-gradle-plugin'

3. 项目的配置文件介绍

CycloneDX Gradle 插件的配置主要在 build.gradle 文件中进行。以下是一些关键配置项的介绍:

cyclonedxBom 配置块

cyclonedxBom {
    // 包含的配置名称列表
    includeConfigs = ["runtimeClasspath"]
    // 跳过的配置名称列表
    skipConfigs = ["compileClasspath", "testCompileClasspath"]
    // 项目类型
    projectType = "application"
    // 使用的 CycloneDX 模式版本
    schemaVersion = "1.6"
    // 输出目录
    destination = file("build/reports")
    // 输出文件名
    outputName = "bom"
    // 输出格式,可以是 xml、json 或 all
    outputFormat = "json"
    // 是否包含 BOM 序列号
    includeBomSerialNumber = false
    // 是否包含许可证文本
    includeLicenseText = true
    // 组件版本
    componentVersion = "2.0.0"
    // 组件名称
    componentName = "my-component"
}

通过这些配置项,可以控制生成的 SBOM(软件物料清单)的详细信息和格式。

总结

CycloneDX Gradle 插件是一个强大的工具,用于从 Gradle 项目生成 CycloneDX SBOM。通过了解项目的目录结构、启动文件和配置文件,可以更好地使用和定制该插件。

cyclonedx-gradle-pluginCreates CycloneDX Software Bill of Materials (SBOM) from Gradle projects项目地址:https://gitcode.com/gh_mirrors/cy/cyclonedx-gradle-plugin

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潘惟妍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值