Skip to content

Commit b404fd3

Browse files
committed
[docs] plugins-tutorial: improve the story around creating config.properties
(cherry picked from commit af324ef)
1 parent 1a62acc commit b404fd3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

docs/src/user-guide/plugins/quick-start.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,32 @@ plugins:
175175
1. `#!yaml <plugin-id>: enabled` is a shorthand; </br>
176176
`#!yaml <plugin-id>: { enabled: true }` is the full form
177177

178-
If we now run the build, we'll see that our generated `com.example.Config` object is present and is visible in the IDE,
178+
If we now run the build, it will fail with an error from our `generateSources` task:
179+
```
180+
ERROR: Task ':app:generate@build-config' failed: java.lang.IllegalStateException: The file /path/to/project/app/config.properties does not exist
181+
at com.example.GenerateSourcesKt.generateSources(generateSources.kt:19)
182+
```
183+
184+
That's because we haven't created the `config.properties` file yet, and the code of the task checks for that.
185+
Let's fix it and create the file. As declared in the `plugin.yaml` above, the file is expected in
186+
`${module.rootDir}/config.properties`:
187+
188+
```yaml hl_lines="4" title="build-config/plugin.yaml"
189+
tasks:
190+
generate:
191+
action: !com.example.generateSources
192+
propertiesFile: ${module.rootDir}/config.properties
193+
generatedSourceDir: ${taskOutputDir}
194+
# ...the rest is omitted for brevity
195+
```
196+
197+
In our case, it is `<root>/app/config.properties`. Let's create it with the following content:
198+
199+
```properties
200+
APP_NAME=My Cool App
201+
```
202+
203+
If we run the build again, we'll see that our generated `com.example.Config` object is present and is visible in the IDE,
179204
and `"Generating sources"` is being logged to the console.
180205

181206
Now let's explore what else we can enhance about our plugin:

0 commit comments

Comments
 (0)