Michael Wiles Michael Wiles - 2 months ago 24
Java Question

Add generated build file to classpath

During my build I generate a build.properties files via the maven properties plugin (properties-maven-plugin) containing build information.

What's the best way to have this file included in the generated jar? I don't want to put it into the src/main/resources directory as this would pollute my default resource directory.

Is there not a "generated-resources" directory as there is with source?

Answer

I thought there was a default generated-resources directory, but I can't find any documentation on that at the moment. You can always configure additional resource directories in your pom:

<build>
    <resources>
        <resource>
            <directory>${basedir}/src/main/resources</directory>
        </resource>
        <resource>
            <directory>${project.build.directory}/generated-resources</directory>
        </resource>
    </resources>
    ...
</build>