问题
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?
回答1:
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>
回答2:
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.
回答3:
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.
回答4:
you can output your files to any directory and add that resource directory to your <resources>
of your <build>
回答5:
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
来源:https://stackoverflow.com/questions/9292908/add-generated-build-file-to-classpath