diff --git a/CHANGELOG.md b/CHANGELOG.md index cc4343d..df92325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.0.0 + +* [**#5** Kotlin KAPT Support](https://github.com/Scalified/gradle-sourcegen-plugin/issues/5) + # 1.2.0 * [**#4** Change Default Location to 'src/main/generated](https://github.com/Scalified/gradle-sourcegen-plugin/issues/4) diff --git a/build.gradle.kts b/build.gradle.kts index f3539a6..bbdd8d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ allprojects { group = "com.scalified" - version = "1.2.0" + version = "2.0.0" repositories { mavenCentral() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4a6ebce..4d9ca16 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sourcegen/build.gradle.kts b/sourcegen/build.gradle.kts index 23315a1..0489a17 100644 --- a/sourcegen/build.gradle.kts +++ b/sourcegen/build.gradle.kts @@ -23,9 +23,9 @@ * */ plugins { - kotlin("jvm") version "1.3.70" + kotlin("jvm") version "1.4.20" - id("com.gradle.plugin-publish") version "0.10.1" + id("com.gradle.plugin-publish") version "0.12.0" `java-gradle-plugin` } @@ -47,3 +47,7 @@ gradlePlugin { } } } + +dependencies { + compileOnly(kotlin("gradle-plugin")) +} diff --git a/sourcegen/src/main/kotlin/com/scalified/plugins/gradle/sourcegen/Extensions.kt b/sourcegen/src/main/kotlin/com/scalified/plugins/gradle/sourcegen/Extensions.kt deleted file mode 100644 index e13bd14..0000000 --- a/sourcegen/src/main/kotlin/com/scalified/plugins/gradle/sourcegen/Extensions.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2020 Scalified - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -package com.scalified.plugins.gradle.sourcegen - -import org.gradle.api.Project -import org.gradle.api.plugins.ExtensionAware -import org.gradle.api.tasks.SourceSet -import org.gradle.api.tasks.SourceSetContainer - -/** - * @author shell - * @since 2020-03-10 - */ -internal val Project.sourceSets: SourceSetContainer - get() = (this as ExtensionAware).extensions.getByName("sourceSets") as SourceSetContainer - -internal fun Project.sourceSet(name: String): SourceSet = project.sourceSets.getByName(name) as SourceSet diff --git a/sourcegen/src/main/kotlin/com/scalified/plugins/gradle/sourcegen/SourceGenPlugin.kt b/sourcegen/src/main/kotlin/com/scalified/plugins/gradle/sourcegen/SourceGenPlugin.kt index b7ba64e..d243552 100644 --- a/sourcegen/src/main/kotlin/com/scalified/plugins/gradle/sourcegen/SourceGenPlugin.kt +++ b/sourcegen/src/main/kotlin/com/scalified/plugins/gradle/sourcegen/SourceGenPlugin.kt @@ -29,6 +29,7 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.compile.JavaCompile import org.gradle.plugins.ide.idea.IdeaPlugin +import org.jetbrains.kotlin.gradle.internal.KaptTask import org.slf4j.LoggerFactory /** @@ -37,6 +38,10 @@ import org.slf4j.LoggerFactory */ private const val JAVA_COMPILE_TASK_NAME = "compileJava" +private const val KAPT_PLUGIN = "org.jetbrains.kotlin.kapt" + +private const val KAPT_TASK = "kaptKotlin" + private const val CLEAN_TASK_NAME = "clean" private const val ANNOTATION_PROCESSOR_CONFIGURATION = "annotationProcessor" @@ -78,6 +83,11 @@ open class SourceGenPlugin : Plugin { javaCompileTask.options.annotationProcessorGeneratedSourcesDirectory = file logger.debug("Configured JavaCompile task") + if (project.plugins.hasPlugin(KAPT_PLUGIN)) { + val kaptTask = project.tasks.getByName(KAPT_TASK) as KaptTask + kaptTask.destinationDir = file + } + val cleanTask = project.tasks.getByName(CLEAN_TASK_NAME) cleanTask.doFirst { if (file.exists()) {