在打包最终的WAR文件之前,如何在maven中解压缩后包含一个资源文件夹

时间:2013-10-16 22:21:24

标签: maven amazon-web-services maven-plugin elastic-beanstalk

背景

为了使用配置文件自定义AWS的Elastic Beanstalk的新方法,我需要在.ebextensions文件夹中提供YAML配置文件,并将其放在WAR文件结构的根目录下,然后将其部署到tomcat 。

我真的想避免将配置文件放在源代码库中,因为它具有特定于部署Web应用程序的OS的命令。我觉得这些配置文件不应该与Web应用程序的源代码相结合。

问题

现在问题是我需要获取此配置文件,包括.ebextensions某种方式&然后在maven创建最终WAR文件之前将它们放在根目录中,准备部署。

由于我需要维护将配置文件放在特定文件夹中的目录结构,我只能提供一个zip文件,然后需要解压缩&然后通过maven放入WAR文件的根目录。

我的问题是,有没有办法通过maven自动执行此操作,或者我需要采取不同的方法。

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:0)

我最终编写了一个在运行构建作业之前执行的shell脚本。如下,

# This set of of commands will fetch the EC2 customization commands from S3 & package it inside the WAR file which will be then deployed to the server.
pwd
ls -la
# Create "temp" directory to put the fetched configs in to.
mkdir -p temp
ls -la temp/
rm -rf temp/*
cd temp
# Fetch the configs
s3cmd sync -vrf s3://tanzchantz.cdn/resources/configuration/ebs/customize-webapps-container/ .
tree -afphug .
# Copy the configs in to webapp directory
cp -rv . ../webapps-main/src/main/webapp/
cd ..
ls -la webapps-main/src/main/webapp/
相关问题