开发者

How do I include configuration files with Maven Appassembler?

开发者 https://www.devze.com 2022-12-16 13:42 出处:网络
I\'m using the Maven Appassembler plugin to package my application. I\'d like to package some confi开发者_运维百科guration files with the application. I\'ve found the configurationDirectory and includ

I'm using the Maven Appassembler plugin to package my application. I'd like to package some confi开发者_运维百科guration files with the application. I've found the configurationDirectory and includeConfigurationDirectoryInClasspath parameters, but I haven't found how I should create (and populate) that configuration directory. I've tried putting the files in src/main/resources, but that just puts them in the jar file for my project.

What is the "proper" way to do this, using maven?


Unfortunately this is a limitation of the appassembler plugin in the current release version. Typically, the plugin is used in conjunction with the assembly plugin to produce the final artifact, in which you can include the reference to your configuration directory. However, if you'd like to have a functional structure from just the appassembler plugin you need to manually copy the files into place. An example using the antrun plugin with a src/main/conf directory can be found here: http://svn.apache.org/viewvc/archiva/trunk/archiva-jetty/


By default, the plugin uses the directory src/main/config.

Is possible to change the source for the config files using the parameter <configurationSourceDirectory>src/main/config</configurationSourceDirectory>


When I include the copyConfigurationDirectory property, it copies the config files and bundles them properly.

  <configurationDirectory>etc</configurationDirectory>
  <configurationSourceDirectory>src/main/config</configurationSourceDirectory>
  <copyConfigurationDirectory>true</copyConfigurationDirectory>

I have a different problem though. I would like to filter my config files before copying, which is giving me some trouble.


Apart from that is does not generate the bin scripts for different platforms. The maven-assembly-plugin can create (package(s) {tar.gz, zip}) for distribution. These are configured through a assemble.xml. You specify which files go in (with what options (chmod)), etc. It can also filter files (search/replace values within them). etc.


Years later and in version 1.10 of the plugin there is now a preAssembleDirectory configuration option. Unfortunately I don't find it flexible enough for my needs because it copies directly into assembleDirectory and does not allow to specify a target directory path within assembleDirectory.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号