Skip to content

Commit

Permalink
#51: Provide a gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiens12357 committed Mar 10, 2023
1 parent 684e6ef commit d95b238
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
12 changes: 12 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
plugins {
java
`maven-publish`
`java-gradle-plugin`
id("com.diffplug.spotless") version "6.12.0"
id("org.jetbrains.kotlin.jvm") version "1.8.10"
id("org.jlleitschuh.gradle.ktlint") version "11.2.0"
Expand All @@ -25,6 +26,8 @@ dependencies {
compileOnly("org.apache.maven.plugin-tools:maven-plugin-annotations:3.7.1")
implementation("org.freemarker:freemarker:2.3.32")
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.7.20")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.2")
}

publishing {
Expand Down Expand Up @@ -58,3 +61,12 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> {
ktlint()
}
}

gradlePlugin {
plugins {
create("CamundaBpmnDocumentationGenerator") {
id = "info.novatec.cbdg"
implementationClass = "info.novatec.cbdg.plugin.CamundaBpmnDocumentationGenerator"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package info.novatec.cbdg.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.provider.Property

interface CamundaBpmnDocumentationGeneratorConfiguration {
val message: Property<String>
}

class CamundaBpmnDocumentationGenerator : Plugin<Project> {

override fun apply(project: Project) {
// Add the 'greeting' extension object
val configuration = project.extensions.create("bu", CamundaBpmnDocumentationGeneratorConfiguration::class.java)
configuration.message.convention("Bu Ga Ga!")
// Add a task that uses configuration from the extension object

project.task("generate").doLast {
println(configuration.message.get())
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package info.novatec.cbdg.plugin

import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

class CamundaBpmnDocumentationGeneratorTest {

@Test
fun greetingTest() {
val project: Project = ProjectBuilder.builder().build()

project.getPluginManager().apply("info.novatec.cbdg")

assertTrue(project.getPluginManager().hasPlugin("info.novatec.cbdg"))
assertNotNull(project.getTasks().getByName("generate"))
}
}

0 comments on commit d95b238

Please sign in to comment.