44![ GitHub Actions Workflow Status] ( https://img.shields.io/github/actions/workflow/status/rio-cloud/gradle-gdpr-documentation-plugin/build-and-deploy.yaml )
55
66Gradle plugin to generate data classification documentation (needed for the GDPR documentation) for your project based
7- on annotations on data classes.
7+ on annotations on data classes and/or from configuration files .
88
99## Disclaimer
1010
@@ -13,18 +13,136 @@ on annotations on data classes.
1313> make sure to classify the data according to your own requirements. RIO is not responsible for your documentation.
1414
1515> [ !NOTE]
16- > RIO maintains this repository for their internal documentation. If you need different / additional functionality, please fork the project.
16+ > RIO maintains this repository for their internal documentation. If you need different / additional functionality,
17+ > please fork the project.
1718
1819## Usage
1920
20- See [ example project] ( ./test ) .
21+ ### Classify your data
22+
23+ There are two ways to classify data:
24+
25+ 1 . Annotate your data classes with the provided annotations
26+ 2 . Provide configuration files
27+
28+ You can also combine both approaches. In case of conflicts, the configuration files will have precedence over the
29+ annotations.
30+
31+ See [ example project] ( ./test ) for examples of both approaches.
32+
33+ #### Annotations
34+
35+ You can annotate your data classes with the following annotations (defined
36+ in [ GdprData] ( ./core/src/main/kotlin/cloud/rio/gdprdoc/annotations/GdprDoc.kt ) ), describing the data flow and purpose:
37+
38+ - ` @Incoming ` to mark incoming data (e.g. from a REST API)
39+ - ` @Outgoing ` to mark outgoing data (e.g. as a response to an API call from another service)
40+ - ` @Persisted ` to mark persisted data (e.g. in a database)
41+ - ` @ReadModel ` to mark read models (e.g. in a CQRS setup)
42+
43+ You can also use multiple of these annotations on a single class. Note that ` @ReadModel ` will automatically classify the
44+ data both as incoming and as persisted.
45+
46+ You can document the PII level of each field in the class with the ` @Field ` annotation which accepts the following enum
47+ values as parameter:
48+
49+ - ` PII `
50+ - ` PSEUDONYM `
51+ - ` NON_PII `
52+
53+ #### Configuration files
54+
55+ You can also provide one or multiple configuration files in yaml format to classify your data.
56+
57+ Each configuration file consists of a list of classes, containing the fully qualified class name, one or multiple blocks
58+ describing the data flow and purpose of the data (analogous to the annotations), and a list of fields with their PII
59+ level.
60+
61+ The following example illustrates the structure of the configuration file:
62+
63+ ``` yaml
64+ classes :
65+ - className : cloud.rio.example.adapter.restclient.IncomingDTO
66+ incoming :
67+ whatToDo : Forward via API
68+ whereFrom : Some external service
69+ links :
70+ - cloud.rio.example.adapter.rest.OutgoingDTO
71+ fields :
72+ - name : id
73+ level : PSEUDONYM
74+ - name : name
75+ level : PII
76+ - name : description
77+ level : NON_PII
78+ - className : cloud.rio.example.adapter.rest.OutgoingDTO
79+ outgoing :
80+ sharedWith : Exposed via API
81+ why : Display in frontend
82+ links :
83+ - cloud.rio.example.adapter.restclient.IncomingDTO
84+ fields :
85+ ...
86+ - className : cloud.rio.example.adapter.db.PersistedEntity
87+ persisted :
88+ retention : 6 months
89+ responsibleForDeletion : Automatic deletion job
90+ links : []
91+ fields :
92+ ...
93+ - className : cloud.rio.example.adapter.readmodel.ReadModel
94+ readModel :
95+ whatToDo : Persist in DB
96+ whereFrom : Some external service
97+ retention : 6 months
98+ responsibleForDeletion : Automatic deletion job
99+ links : []
100+ fields :
101+ ...
102+ ` ` `
103+
104+ ### Apply and configure the plugin
105+
106+ To use the plugin, add the plugin to the plugins block of your ` build.gradle.kts` file and add the core dependency to
107+ the compile time classpath :
108+
109+ ` ` ` kotlin
110+ plugins {
111+ id("cloud.rio.gdprdoc") version "2.0.1"
112+ }
113+
114+ dependencies {
115+ compileOnly("cloud.rio.gdprdoc:core:2.0.1")
116+ }
117+ ` ` `
118+
119+ You can configure the documentation generation task to change the output file name and location, and to specify the
120+ configuration files to use, for example in the following way :
121+
122+ ` ` ` kotlin
123+ tasks {
124+ generateGdprDocumentation {
125+ markdownReport = file("docs/gdpr/gdpr-documentation.md")
126+ additionalGdprDataFiles.setFrom(
127+ fileTree("src/main/resources") { include("**/gdpr-documentation.yaml") },
128+ )
129+ }
130+ }
131+ ` ` `
132+
133+ By default, the output will be written to `build/reports/gdpr-documentation.md`, and no configuration files will be
134+ used.
135+
136+ # ## Generate the documentation
21137
22138Generate the documentation by running :
139+
23140` ` `
24141./gradlew generateGdprDocumentation
25142` ` `
26- You find the documentation in ` build/reports/gdpr-documentation.md ` . It currently needs to be manually
27- copied to ` docs/gdpr-documentation.md `
143+
144+ You find the documentation in `build/reports/gdpr-documentation.md` unless you configured a different location (see
145+ above).
28146
29147Make sure to enable PlantUML in your markdown renderer in your IDE to see the Data Flow Diagram.
30148Backstage also supports PlantUML, so it should work there without additional setup.
@@ -34,54 +152,61 @@ Backstage also supports PlantUML, so it should work there without additional set
34152# ## CI/CD pipeline
35153
36154This plugin uses GitHub actions to build and deploy the plugin to the Gradle Plugin Portal.
37- The workflow is defined in ` .github/workflows/build-and-deploy.yaml ` and triggered on every push
155+ The workflow is defined in `.github/workflows/build-and-deploy.yaml`and triggered on every push
38156to the `main` branch and on every pull request.
39157
40158# ## Dependabot
41- This repository uses [ dependabot] ( https://dependabot.com/ ) to keep dependencies up to date.
159+
160+ This repository uses [dependabot](https://dependabot.com/) to keep dependencies up to date.
42161Dependabot is configured in `.github/dependabot.yaml`.
43162
44163# ## Release process
45164
46- The workflow uses the [ release-please-action from Google] ( https://github.com/googleapis/release-please-action ) .
165+ The workflow uses the [release-please-action from Google](https://github.com/googleapis/release-please-action).
47166
48- > Release Please assumes you are using Conventional Commit messages.
167+ > _release-please_ assumes you are using Conventional Commit messages.
49168>
50169> The most important prefixes you should have in mind are:
51170>
52171> fix: which represents bug fixes, and correlates to a SemVer patch.
53172>
54173> feat: which represents a new feature, and correlates to a SemVer minor.
55174>
56- > feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
175+ > feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer
176+ > major.
57177
58- When release-please detects one or more conventional commits, it will create or update a pull request.
178+ When release-please detects one or more conventional commits, it will create or update a pull request.
59179Once the pull request is merged, the workflow will create a new release and deploy the plugin.
60180
61181# ## Manually trigger the release process
62182
63183All commits not following the conventional commit format will be ignored by the release-please-action.
64184Examples include :
185+
65186- updating documentation
66187- merge dependabot updates
67188- ...
68189
69190To trigger the action simply create an empty commit following the conventional commit format, e.g. :
191+
70192` ` `
71193git commit --allow-empty -m "fix: prepare next release. Update dependencies"
72194git push
73195` ` `
74196
75197# ## Secret management
76- The required secrets for the GitHub actions are stored in the repository settings under "Secrets and variables" -> "Actions".
77- Currently, they are not managed as code.
198+
199+ The required secrets for the GitHub actions are stored in the repository settings under "Secrets and variables" -> "
200+ Actions".
201+ Currently, they are not managed as code.
78202
79203# ## Build and test the plugin
204+
80205```
81206./gradlew clean build
82207```
83208
84- ### Build and the the example project
209+ ### Build and test the example project
85210
86211```
87212cd test
0 commit comments