@@ -9,14 +9,8 @@ Doma CodeGen Plugin is a Gradle plugin that generates Java, Kotlin, and SQL file
99## Build Commands
1010
1111``` bash
12- # Build entire project with code formatting
13- ./gradlew spotlessApply build
14-
15- # Build only the plugin module
16- ./gradlew :codegen:build
17-
18- # Clean build
19- ./gradlew clean build
12+ # Build the codegen plugin
13+ ./gradlew build
2014```
2115
2216## Testing Commands
@@ -27,47 +21,57 @@ Doma CodeGen Plugin is a Gradle plugin that generates Java, Kotlin, and SQL file
2721
2822# Run specific module tests
2923./gradlew :codegen:test
30- ./gradlew :codegen-test:test
31-
32- # Test code generation (from codegen-test directory)
33- cd codegen-test
34- ./gradlew domaCodeGenJavaAll build
35- ./gradlew domaCodeGenKotlinAll build
24+ ./gradlew :codegen-h2-test:test
25+ ./gradlew :codegen-tc-test:test
3626```
3727
3828## Code Quality
3929
4030``` bash
4131# Apply code formatting (required before commits)
42- ./gradlew spotlessApply
32+ ./gradlew :codegen: spotlessApply
4333
4434# Check code formatting
45- ./gradlew spotlessCheck
35+ ./gradlew :codegen: spotlessCheck
4636```
4737
4838## Architecture Overview
4939
5040### Multi-Module Structure
51- - ** codegen** : Main plugin implementation
41+ This is a Gradle composite build with the following structure:
42+
43+ - ** Root project** (` doma-codegen-plugin ` ): Contains build configuration and release management
44+ - Uses ` pluginManagement ` with ` includeBuild("codegen") ` to include the plugin project
45+ - Includes test modules: ` codegen-h2-test ` and ` codegen-tc-test `
46+
47+ - ** codegen** : Main plugin implementation (included build)
5248 - Plugin entry point: ` CodeGenPlugin.java `
5349 - Tasks defined in ` org.seasar.doma.gradle.codegen.task ` package
5450 - Code generators in ` org.seasar.doma.gradle.codegen.generator ` package
5551 - Database dialects in ` org.seasar.doma.gradle.codegen.dialect ` package
52+ - Has its own ` settings.gradle.kts ` and ` gradle.properties `
53+ - Uses Groovy for some components (see ` src/main/groovy ` )
5654
57- - ** codegen-test** : Integration test project demonstrating plugin usage
55+ - ** codegen-h2-test** : Integration test module using H2 database
56+ - Tests code generation with in-memory H2 database
57+ - Uses the plugin via ` id("org.domaframework.doma.codegen") `
58+ - Single configuration: ` h2 `
59+
60+ - ** codegen-tc-test** : Integration test module using Testcontainers
61+ - Tests code generation with PostgreSQL via Testcontainers
62+ - Supports both Java and Kotlin code generation
63+ - Two configurations: ` java ` and ` kotlin `
5864
5965### Key Components
6066
61671 . ** Code Generators** : Transform database metadata into Java/Kotlin code using FreeMarker templates
62- - ` JavaGenerator ` : Generates Java entities and DAOs
63- - ` KotlinGenerator ` : Generates Kotlin entities and DAOs
64- - ` SqlGenerator ` : Generates SQL template files
6568
66692 . ** Database Dialects** : Database-specific implementations for metadata extraction
6770 - Supports: H2, MySQL, Oracle, PostgreSQL, SQL Server, DB2, HSQLDB
6871
69723 . ** Gradle Tasks** : Plugin provides tasks prefixed with ` domaCodeGen `
70- - Pattern: ` domaCodeGen{Java|Kotlin|Sql}{EntityName|All} `
73+ - Pattern: ` domaCodeGen{ConfigName}{Java|Kotlin|Sql}{EntityName|All} `
74+ - Example: ` domaCodeGenH2JavaAll ` , ` domaCodeGenKotlinEntityEmployee `
7175
72764 . ** Template System** : FreeMarker templates in ` /codegen/src/main/resources/ `
7377 - Customizable via ` templateDir ` configuration
@@ -83,11 +87,27 @@ cd codegen-test
8387
8488### Database Connection
8589
86- The plugin connects to databases to read metadata. Configure in build.gradle:
90+ The plugin connects to databases to read metadata. Configure in build.gradle.kts :
8791``` kotlin
8892domaCodeGen {
89- url = " jdbc:h2:mem:example"
90- user = " sa"
91- password = " "
93+ register(" myConfig" ) {
94+ url = " jdbc:h2:mem:example"
95+ user = " sa"
96+ password = " "
97+ entity {
98+ packageName = " com.example.entity"
99+ }
100+ dao {
101+ packageName = " com.example.dao"
102+ }
103+ }
92104}
93- ```
105+ ```
106+
107+ ### Important Notes
108+
109+ - The plugin is published to Gradle Plugin Portal (not Maven Central)
110+ - In development, test modules apply the plugin using ` id("org.domaframework.doma.codegen") ` which resolves to the local included build
111+ - Each configuration in ` domaCodeGen ` block creates its own set of tasks
112+ - The ` domaCodeGen ` configuration is used for JDBC driver dependencies
113+ - CI uses JDK 21 for builds, but the plugin targets Java 17 compatibility
0 commit comments