Skip to content

Commit

Permalink
feat: add nemerosa versioning plugin (#3)
Browse files Browse the repository at this point in the history
* feat: add nemerosa versioning plugin

* chore: change version to full in local development

* chore: remove gradle properties/minor improvements

* chore: move plugin properties to build folder

* chore(generate-vex): remove default value from props for metadata

---------

Co-authored-by: Patrick Mirwald <mirwald@liftric.com>
  • Loading branch information
nvima and Patrick Mirwald authored Jul 18, 2023
1 parent 4e28099 commit 6e595c1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
33 changes: 22 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ plugins {
alias(libs.plugins.kotlinSerialization)
alias(libs.plugins.dockerCompose)
alias(libs.plugins.gradlePluginPublish)
alias(libs.plugins.versioning)
}

group = "com.liftric"
version = with(versioning.info) {
if (branch == "HEAD" && dirty.not()) tag else full
}

repositories {
Expand All @@ -23,6 +29,7 @@ dockerCompose {
}

val integrationTest = sourceSets.create("integrationTest")

tasks {
val test by existing
withType<Test> {
Expand All @@ -43,28 +50,32 @@ tasks {
}
dockerCompose.isRequiredBy(integrationTestTask)

val pluginPropertiesBuildFolder = file("$buildDir/compileProperties/")
val propertiesTask = register<WriteProperties>("writePluginProperties") {
outputFile = file("src/main/resources/plugin.properties")
property("vendor", project.property("pluginVendor").toString())
property("name", project.property("pluginName").toString())
property("version", project.property("pluginVersion").toString())
outputFile = pluginPropertiesBuildFolder.resolve("plugin.properties")
property("vendor", "Liftric")
property("name", rootProject.name)
property("version", rootProject.version)
}
sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).resources.srcDir(pluginPropertiesBuildFolder)

withType(ProcessResources::class.java) {
dependsOn(propertiesTask)
}
}

tasks.named("build") {
tasks.named("publishPlugins") {
dependsOn("writePluginProperties")
}


gradlePlugin {
testSourceSets(integrationTest)
plugins {
create("dependency-track-companion-plugin") {
id = "${project.property("pluginGroup")}.${project.property("pluginName")}"
implementationClass = "${project.property("pluginGroup")}.dtcp.DepTrackCompanionPlugin"
displayName = project.property("pluginName").toString()
version = project.property("pluginVersion").toString()
group = project.property("pluginGroup").toString()
id = "$group.$name"
implementationClass = "$group.dtcp.DepTrackCompanionPlugin"
displayName = name
description = "Common tasks for Dependency Track interaction, like SBOM upload or VEX Generation"
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
kotlin.code.style=official
pluginGroup=com.liftric
pluginVersion=1.0.0
pluginName=dependency-track-companion-plugin
pluginVendor=Liftric
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pluginManagement {
version("cyclonedx-core-java", "7.3.2")
version("junit-bom", "5.9.3")

plugin("versioning", "net.nemerosa.versioning").version("3.0.0")
plugin("dockerCompose", "com.avast.gradle.docker-compose").version("0.16.12")
plugin("kotlinJvm", "org.jetbrains.kotlin.jvm").versionRef("kotlin")
plugin("kotlinSerialization", "org.jetbrains.kotlin.plugin.serialization").versionRef("kotlin")
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/liftric/dtcp/tasks/GenerateVex.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ abstract class GenerateVexTask : DefaultTask() {
vexFile.metadata.timestamp = Date()
vexFile.metadata.component = sbom.metadata.component ?: Component()
val pluginData = Tool().apply {
vendor = props.getProperty("vendor", "Liftric")
name = props.getProperty("name", "Liftric")
version = props.getProperty("version", "Liftric")
vendor = props.getProperty("vendor")
name = props.getProperty("name")
version = props.getProperty("version")
}
vexFile.metadata.tools = listOf(pluginData)
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/plugin.properties

This file was deleted.

0 comments on commit 6e595c1

Please sign in to comment.