Michael Wiles
Michael Wiles

Reputation: 21186

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?

Upvotes: 7

Views: 20047

Answers (5)

wemu
wemu

Reputation: 8160

Place generated sources in target/generated-sources

There is a plugin called build-helper that allows you to add that folder to the source-folders list.

Upvotes: 1

Hurda
Hurda

Reputation: 4715

You should put it in the target/classes directory

(fixed now from just target) and I think that this is better than the accepted one. As there is no need to process this resource as resource anymore

Upvotes: -4

Jörn Horstmann
Jörn Horstmann

Reputation: 34014

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>

Upvotes: 22

Guillaume Polet
Guillaume Polet

Reputation: 47608

you can output your files to any directory and add that resource directory to your <resources> of your <build>

Upvotes: 0

Erhan Bagdemir
Erhan Bagdemir

Reputation: 5327

You can use maven assembly plugin to organize files and filesets in packages. have a look at http://maven.apache.org/plugins/maven-assembly-plugin/advanced-descriptor-topics.html I think it is what you need.

Upvotes: 0

Related Questions