Skip to content

Commit a74615d

Browse files
authored
Merge pull request #90 from domaframework/feat/gradle-increment-annotation-processing
Enable Gradle's Incremental Annotation Processing
2 parents c2e1f9c + 78b7bc4 commit a74615d

File tree

6 files changed

+59
-109
lines changed

6 files changed

+59
-109
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@ jobs:
3535
- name: Build plugin
3636
run: ./gradlew build
3737

38-
- name: Test plugin against Java
39-
working-directory: ./compile-java-test
40-
run: ./gradlew build
41-
42-
- name: Test plugin against Kotlin
43-
working-directory: ./compile-kotlin-test
44-
run: ./gradlew build
45-
46-
- name: Test plugin against a mix of Java and Kotlin
47-
working-directory: ./compile-mix-test
48-
run: ./gradlew build
38+
# TODO
39+
# - name: Test plugin against Java
40+
# working-directory: ./compile-java-test
41+
# run: ./gradlew build
42+
#
43+
# - name: Test plugin against Kotlin
44+
# working-directory: ./compile-kotlin-test
45+
# run: ./gradlew build
46+
#
47+
# - name: Test plugin against a mix of Java and Kotlin
48+
# working-directory: ./compile-mix-test
49+
# run: ./gradlew build
4950

5051
- name: Set version
5152
id: set-version

.sdkmanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Enable auto-env through the sdkman_auto_env config
22
# Add key=value pairs of SDKs to use below
3-
java=21-zulu
3+
java=17.0.14-tem
44

README.md

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,38 @@
11
Doma Compile Plugin
22
===================
33

4-
Doma compile plugin is a gradle plugin.
5-
It allows annotation processors to read Doma resources at compile-time.
4+
The Doma Compile Plugin is a Gradle plugin that allows annotation processors to read Doma resources at compile-time.
65

7-
The plugin supports Java and Kotlin.
6+
The plugin supports both Java and Kotlin.
87

98
[![Java CI with Gradle](https://github.com/domaframework/doma-compile-plugin/workflows/Java%20CI%20with%20Gradle/badge.svg)](https://github.com/domaframework/doma-compile-plugin/actions?query=workflow%3A%22Java+CI+with+Gradle%22)
10-
[![project chat](https://img.shields.io/badge/zulip-join_chat-green.svg)](https://domaframework.zulipchat.com)
9+
[![Project Chat](https://img.shields.io/badge/zulip-join_chat-green.svg)](https://domaframework.zulipchat.com)
1110
[![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](https://twitter.com/domaframework)
1211

13-
How to use
12+
How to Use
1413
----------
1514

16-
See [Gradle Plugin Portal](https://plugins.gradle.org/plugin/org.domaframework.doma.compile).
15+
See the [Gradle Plugin Portal](https://plugins.gradle.org/plugin/org.domaframework.doma.compile).
1716

18-
What does the plugin do ?
17+
What Does the Plugin Do?
1918
-------------------------
2019

21-
The plugin is equivalent to the following gradle script:
20+
The plugin is equivalent to the following Gradle Kotlin DSL script:
2221

23-
```groovy
24-
def domaResources = ['doma.compile.config', 'META-INF/**/*.sql', 'META-INF/**/*.script']
25-
26-
task copyDomaResourcesJava(type: Copy) {
27-
from sourceSets.main.resources.srcDirs
28-
into compileJava.destinationDir
29-
include domaResources
30-
}
31-
32-
compileJava {
33-
dependsOn copyDomaResourcesJava
34-
}
35-
36-
processResources {
37-
exclude domaResources
38-
}
39-
40-
task copyDomaResourcesKotlin(type: Copy) {
41-
from sourceSets.main.resources.srcDirs
42-
into compileKotlin.destinationDir
43-
include domaResources
44-
}
45-
46-
compileKotlin {
47-
dependsOn copyDomaResourcesKotlin
22+
```kotlin
23+
tasks {
24+
compileJava {
25+
val resourceDirs = sourceSets.getByName("main").resources.srcDirs
26+
options.sourcepath = files(resourceDirs)
27+
options.compilerArgs.add("-parameters")
28+
}
4829
}
4930

5031
kapt {
51-
arguments {
52-
arg('doma.resources.dir', compileKotlin.destinationDir)
32+
javacOptions {
33+
val resourceDirs = sourceSets.getByName("main").resources.srcDirs
34+
option("--source-path", resourceDirs.join(File.pathSeparator))
35+
option("-parameters")
5336
}
5437
}
5538
```
@@ -60,28 +43,31 @@ Example build.gradle.kts
6043
- Java: https://github.com/domaframework/simple-examples/blob/master/build.gradle.kts
6144
- Kotlin: https://github.com/domaframework/kotlin-sample/blob/master/build.gradle.kts
6245

63-
Major versions
46+
Version Information
6447
---------------------
6548

6649
### Status and Repository
6750

68-
| Version | Status | Repository | Branch |
69-
|-----------------------|-----------------|--------------------------------------------------------------------------------------------|--------|
70-
| Doma Compile Plugin 2 | limited-support | [domaframework/doma-compile-plugin](https://github.com/domaframework/doma-compile-plugin/) | 2.x |
71-
| Doma Compile Plugin 3 | stable | [domaframework/doma-compile-plugin](https://github.com/domaframework/doma-compile-plugin/) | master |
51+
| Version | Status | Repository | Branch |
52+
|-----------------------|------------------|--------------------------------------------------------------------------------------------|--------|
53+
| Doma Compile Plugin 2 | Limited Support | [domaframework/doma-compile-plugin](https://github.com/domaframework/doma-compile-plugin/) | 2.x |
54+
| Doma Compile Plugin 3 | Limited Support | [domaframework/doma-compile-plugin](https://github.com/domaframework/doma-compile-plugin/) | 3.x |
55+
| Doma Compile Plugin 4 | Stable | [domaframework/doma-compile-plugin](https://github.com/domaframework/doma-compile-plugin/) | master |
7256

73-
### Compatibility matrix
57+
### Compatibility Matrix
7458

75-
The supported versions of Doma:
59+
Doma Version Compatibility:
7660

77-
| | Doma 2 | Doma 3 |
78-
|-----------------------|--------|--------|
79-
| Doma Compile Plugin 2 | v | |
80-
| Doma Compile Plugin 3 | | v |
61+
| | Doma 2 | Doma 3.0 - 3.7 | Doma 3.8 or later |
62+
|-----------------------|--------|----------------|-------------------|
63+
| Doma Compile Plugin 2 || | |
64+
| Doma Compile Plugin 3 | || |
65+
| Doma Compile Plugin 4 | | ||
8166

82-
The minimum supported versions of Java:
67+
Java Version Requirements:
8368

84-
| | Java 8 | Java 17 |
85-
|-----------------------|--------|---------|
86-
| Doma Compile Plugin 2 | v | |
87-
| Doma Compile Plugin 3 | | v |
69+
| | Java 8 or later | Java 17 or later |
70+
|-----------------------|------------------|-------------------|
71+
| Doma Compile Plugin 2 || |
72+
| Doma Compile Plugin 3 | ||
73+
| Doma Compile Plugin 4 | ||

compile/src/main/groovy/org/seasar/doma/gradle/compile/ConfigureKotlin.groovy

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ package org.seasar.doma.gradle.compile
33
import org.gradle.api.Project
44
import org.gradle.api.tasks.SourceSet
55

6-
import java.util.function.Supplier
7-
86
class ConfigureKotlin {
97

108
static void configure(Project project, SourceSet sourceSet) {
119
project.plugins.withId('kotlin-kapt') {
12-
def tasks = project.tasks
1310
def kapt = project.extensions.getByName('kapt')
14-
def compileKotlin = tasks.named('compileKotlin')
15-
def dir = compileKotlin.get().destinationDirectory.getAsFile().get()
16-
kapt.arguments { arg('doma.resources.dir', dir) }
17-
def copyResources = tasks.register(CopyResources.NAME + "Kotlin", CopyResources.class, sourceSet, dir)
18-
compileKotlin.configure {
19-
dependsOn copyResources
11+
def resourceDirs = sourceSet.resources.srcDirs
12+
kapt.javacOptions {
13+
option '--source-path', resourceDirs.join(File.pathSeparator)
14+
option '-parameters', ''
2015
}
2116
}
2217
}
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
package org.seasar.doma.gradle.compile;
22

3+
import java.io.File;
4+
import java.util.Set;
35
import org.gradle.api.Project;
46
import org.gradle.api.tasks.SourceSet;
57
import org.gradle.api.tasks.TaskContainer;
6-
import org.gradle.api.tasks.TaskProvider;
78
import org.gradle.api.tasks.compile.JavaCompile;
8-
import org.gradle.language.jvm.tasks.ProcessResources;
99

1010
public class ConfigureJava {
1111

1212
public static void configure(Project project, SourceSet sourceSet) {
1313
TaskContainer tasks = project.getTasks();
14+
Set<File> resourceDirs = sourceSet.getResources().getSrcDirs();
1415

1516
JavaCompile javaCompile =
1617
tasks.named(sourceSet.getCompileJavaTaskName(), JavaCompile.class).get();
17-
TaskProvider<ProcessResources> processResources =
18-
tasks.named(sourceSet.getProcessResourcesTaskName(), ProcessResources.class);
19-
TaskProvider<CopyResources> copyResources =
20-
tasks.register(
21-
CopyResources.NAME + "Java",
22-
CopyResources.class,
23-
sourceSet,
24-
javaCompile.getDestinationDirectory());
25-
26-
javaCompile.dependsOn(copyResources);
27-
processResources.configure(task -> task.exclude(CopyResources.DOMA_RESOURCES));
18+
javaCompile.getOptions().setSourcepath(project.files(resourceDirs));
19+
javaCompile.getOptions().getCompilerArgs().add("-parameters");
2820
}
2921
}

compile/src/main/java/org/seasar/doma/gradle/compile/CopyResources.java

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

0 commit comments

Comments
 (0)