Skip to content

Commit 730a39c

Browse files
authored
Merge pull request #112 from martinbonnin/remove-kotlin-dsl-plugin
Remove the `kotlin-dsl` plugin
2 parents 916c2d5 + 65f159c commit 730a39c

File tree

5 files changed

+53
-22
lines changed

5 files changed

+53
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Once you setup the plugin correctly, you can call the `:generateSwagger` gradle
5656

5757
In order to run this gradle plugin you need to fulfill the following requirements:
5858

59-
* Gradle 5.x - This plugin uses Gradle 5 features, and you will need to setup your Gradle wrapper to use 5.0 or more.
59+
* Gradle 5.x - This plugin uses Gradle 5 features, and you will need to setup your Gradle wrapper to use 5.4.1 or more.
6060
* Java 8+
6161

6262
## Supported platforms

gradle-plugin/plugin/build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = rootProject.version
55

66
plugins {
77
java
8-
`kotlin-dsl`
8+
id("java-gradle-plugin")
99
`maven-publish`
1010
jacoco
1111
kotlin("jvm") version "1.3.61"
@@ -38,6 +38,14 @@ tasks.register<Jar>("sourcesJar") {
3838
from(sourceSets.main.get().allJava)
3939
classifier = "sources"
4040
}
41+
gradlePlugin {
42+
plugins {
43+
create("com.yelp.codegen.plugin") {
44+
id = "com.yelp.codegen.plugin"
45+
implementationClass = "com.yelp.codegen.plugin.CodegenPlugin"
46+
}
47+
}
48+
}
4149

4250
// Configuration Block for the Plugin Marker artifact on Plugin Central
4351
pluginBundle {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.yelp.codegen.plugin
2+
3+
import org.gradle.api.Plugin
4+
import org.gradle.api.Project
5+
import org.gradle.util.GradleVersion
6+
7+
class CodegenPlugin : Plugin<Project> {
8+
override fun apply(project: Project) {
9+
require(GradleVersion.current() >= GradleVersion.version("5.4.1")) {
10+
"com.yelp.codegen.plugin requires Gradle version 5.4.1 or greater"
11+
}
12+
13+
val config = project.extensions.create("generateSwagger", GenerateTaskConfiguration::class.java, project)
14+
15+
project.tasks.register("generateSwagger", GenerateTask::class.java) {
16+
it.platform = config.platform
17+
it.packageName = config.packageName
18+
it.specName = config.specName
19+
it.specVersion = config.specVersion
20+
it.inputFile = config.inputFile
21+
it.outputDir = config.outputDir
22+
23+
it.extraFiles = config.extraFiles
24+
it.features = config.features
25+
}
26+
}
27+
}

gradle-plugin/plugin/src/main/kotlin/com/yelp/codegen/plugin.gradle.kts

Lines changed: 0 additions & 20 deletions
This file was deleted.

gradle-plugin/plugin/src/test/java/com/yelp/plugin/PluginTests.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,20 @@ class PluginTests {
3232
.build()
3333
Assert.assertEquals(TaskOutcome.UP_TO_DATE, result2ndRun.task(":generateSwagger")?.outcome)
3434
}
35+
36+
@Test
37+
fun testMinSupportdGradleVersion() {
38+
val projectDir = temporaryFolder.newFolder("project")
39+
File("src/test/testProject").copyRecursively(projectDir)
40+
41+
val result = GradleRunner.create()
42+
.withProjectDir(projectDir)
43+
.withGradleVersion("5.4.1")
44+
.forwardStdOutput(System.out.writer())
45+
.forwardStdError(System.err.writer())
46+
.withArguments("generateSwagger")
47+
.build()
48+
49+
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateSwagger")?.outcome)
50+
}
3551
}

0 commit comments

Comments
 (0)