You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/using-the-plugin-in-more-depth.md
+64-2Lines changed: 64 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ Essentially every user can chose between the following alternatives:
5
5
* use plain resource filtering from maven
6
6
* use resource filtering from maven Maven in combination with Spring beans
7
7
* have the plugin generate a `git.properties` inside your artifact
8
+
* Generate a Java Source File with Compile Time Constants
8
9
9
10
The following should give you a broad overview about the different cases.
10
11
@@ -274,8 +275,69 @@ public GitRepositoryState(Properties properties)
274
275
}
275
276
```
276
277
277
-
Yet another way to use the plugin
278
+
Generate A Java Source File with Compile Time Constants
278
279
=================================
279
280
280
-
Rather than reading properties files at runtime or injecting with spring, you can filter a Java source file directly and place it into `src/main/java` with an ignore, or into generatedsources directory within the target directory. This has some minor advantages and disadvantages, but is useful for avoiding runtime injection or lookup from properties files that might get lost during repackaging later if used within a library.
281
+
Rather than reading properties files at runtime or injecting with spring, you can filter a Java source file directly into a `generated-sources` directory within the `target` directory. This is useful for avoiding runtime injection and/or lookup from properties files that might get lost during repackaging later if used within a library.
281
282
283
+
Add the [templating-maven-plugin](https://github.com/mojohaus/templating-maven-plugin) to your pom.xml:
284
+
```xml
285
+
<plugin>
286
+
<groupId>org.codehaus.mojo</groupId>
287
+
<artifactId>templating-maven-plugin</artifactId>
288
+
<version>3.0.0</version>
289
+
<executions>
290
+
<execution>
291
+
<goals>
292
+
<goal>filter-sources</goal>
293
+
</goals>
294
+
<phase>generate-sources</phase>
295
+
</execution>
296
+
</executions>
297
+
</plugin>
298
+
```
299
+
300
+
Add a template .java source file to `src/main/java-templates`:
0 commit comments