Skip to content

Commit e986463

Browse files
nakamura-toclaude
andcommitted
Add support for custom source sets in Doma compile plugin
- Configure Java and Kotlin projects to include custom source directories - Add test cases for entities and DAOs in custom source locations - Defer Kotlin configuration until after project evaluation to ensure proper source set resolution - Update JavaCompileConfigurator to resolve resource directories at task execution time This enables users to define entities and DAOs in non-standard source locations while maintaining Doma's annotation processing capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 517faa3 commit e986463

File tree

15 files changed

+104
-15
lines changed

15 files changed

+104
-15
lines changed

compile-java-test/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ dependencies {
2323
testRuntimeOnly(libs.junit.jupiter.engine)
2424
testRuntimeOnly(libs.junit.platform.launcher)
2525
}
26+
27+
sourceSets {
28+
main {
29+
java.srcDir("src/common/java")
30+
resources.srcDir("src/common/resources")
31+
}
32+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package common;
2+
3+
import org.seasar.doma.Entity;
4+
import org.seasar.doma.Id;
5+
6+
@Entity
7+
public class Department {
8+
@Id public Integer id;
9+
public String name;
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package common;
2+
3+
import org.seasar.doma.Dao;
4+
import org.seasar.doma.Script;
5+
import org.seasar.doma.Select;
6+
7+
@Dao
8+
public interface DepartmentDao {
9+
@Select
10+
Department selectById(Integer id);
11+
12+
@Script
13+
void create();
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
create table department(
2+
id integer not null primary key,
3+
name varchar(20) not null,
4+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select * from department where id = /*id*/0

compile-java-test/src/test/java/example/GenerationTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import static org.junit.jupiter.api.Assertions.assertNotNull;
44

5+
import common.DepartmentDaoImpl;
6+
import common._Department;
57
import org.junit.jupiter.api.Test;
68

79
public class GenerationTest {
@@ -10,5 +12,7 @@ public class GenerationTest {
1012
public void test() {
1113
assertNotNull(_Employee.class);
1214
assertNotNull(EmployeeDaoImpl.class);
15+
assertNotNull(_Department.class);
16+
assertNotNull(DepartmentDaoImpl.class);
1317
}
1418
}

compile-kotlin-test/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ dependencies {
3030
testRuntimeOnly(libs.junit.jupiter.engine)
3131
testRuntimeOnly(libs.junit.platform.launcher)
3232
}
33+
34+
kotlin {
35+
sourceSets {
36+
main {
37+
kotlin.srcDir("src/common/kotlin")
38+
resources.srcDir("src/common/resources")
39+
}
40+
}
41+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package common
2+
3+
import org.seasar.doma.Entity
4+
import org.seasar.doma.Id
5+
6+
@Entity
7+
class Department {
8+
@Id
9+
var id: Int? = null
10+
var name: String? = null
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package common
2+
3+
import org.seasar.doma.Dao
4+
import org.seasar.doma.Script
5+
import org.seasar.doma.Select
6+
7+
@Dao
8+
interface DepartmentDao {
9+
@Select
10+
fun selectById(id: Int?): Department?
11+
12+
@Script
13+
fun create()
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
create table department(
2+
id integer not null primary key,
3+
name varchar(20) not null,
4+
);

0 commit comments

Comments
 (0)