Skip to content

Commit

Permalink
Merge pull request #112 from martinbonnin/remove-kotlin-dsl-plugin
Browse files Browse the repository at this point in the history
Remove the `kotlin-dsl` plugin
  • Loading branch information
cortinico committed Feb 16, 2020
2 parents 916c2d5 + 65f159c commit 730a39c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Once you setup the plugin correctly, you can call the `:generateSwagger` gradle

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

* Gradle 5.x - This plugin uses Gradle 5 features, and you will need to setup your Gradle wrapper to use 5.0 or more.
* 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.
* Java 8+

## Supported platforms
Expand Down
10 changes: 9 additions & 1 deletion gradle-plugin/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = rootProject.version

plugins {
java
`kotlin-dsl`
id("java-gradle-plugin")
`maven-publish`
jacoco
kotlin("jvm") version "1.3.61"
Expand Down Expand Up @@ -38,6 +38,14 @@ tasks.register<Jar>("sourcesJar") {
from(sourceSets.main.get().allJava)
classifier = "sources"
}
gradlePlugin {
plugins {
create("com.yelp.codegen.plugin") {
id = "com.yelp.codegen.plugin"
implementationClass = "com.yelp.codegen.plugin.CodegenPlugin"
}
}
}

// Configuration Block for the Plugin Marker artifact on Plugin Central
pluginBundle {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.yelp.codegen.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.util.GradleVersion

class CodegenPlugin : Plugin<Project> {
override fun apply(project: Project) {
require(GradleVersion.current() >= GradleVersion.version("5.4.1")) {
"com.yelp.codegen.plugin requires Gradle version 5.4.1 or greater"
}

val config = project.extensions.create("generateSwagger", GenerateTaskConfiguration::class.java, project)

project.tasks.register("generateSwagger", GenerateTask::class.java) {
it.platform = config.platform
it.packageName = config.packageName
it.specName = config.specName
it.specVersion = config.specVersion
it.inputFile = config.inputFile
it.outputDir = config.outputDir

it.extraFiles = config.extraFiles
it.features = config.features
}
}
}

This file was deleted.

16 changes: 16 additions & 0 deletions gradle-plugin/plugin/src/test/java/com/yelp/plugin/PluginTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,20 @@ class PluginTests {
.build()
Assert.assertEquals(TaskOutcome.UP_TO_DATE, result2ndRun.task(":generateSwagger")?.outcome)
}

@Test
fun testMinSupportdGradleVersion() {
val projectDir = temporaryFolder.newFolder("project")
File("src/test/testProject").copyRecursively(projectDir)

val result = GradleRunner.create()
.withProjectDir(projectDir)
.withGradleVersion("5.4.1")
.forwardStdOutput(System.out.writer())
.forwardStdError(System.err.writer())
.withArguments("generateSwagger")
.build()

Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateSwagger")?.outcome)
}
}

0 comments on commit 730a39c

Please sign in to comment.