Skip to content

Commit

Permalink
#5 Kotlin KAPT Support
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaidak committed Nov 29, 2020
1 parent 02c8b18 commit 0fc5b28
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
allprojects {

group = "com.scalified"
version = "1.2.0"
version = "2.0.0"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions sourcegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}

Expand All @@ -47,3 +47,7 @@ gradlePlugin {
}
}
}

dependencies {
compileOnly(kotlin("gradle-plugin"))
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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"
Expand Down Expand Up @@ -78,6 +83,11 @@ open class SourceGenPlugin : Plugin<Project> {
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()) {
Expand Down

0 comments on commit 0fc5b28

Please sign in to comment.