Maven - Separating Deployment & Project

2019-05-26 07:14发布

What is the 'best practice' way of separating Maven deployment configuration from the build config?

I have a war project, that is built by Jenkins. I'd like Jenkins to deploy this to Elastic Beanstalk, but alas the best solution available at the moment is to use the beanstalk-maven-plugin.

I'm not sure it makes sense for the POM.xml to include information about deployment; after all, at build time that .war could end up anywhere.

In this situation, is there some way of using Maven modules to store the beanstalk-maven-plugin config in a separate POM to that of the actual software project?

2条回答
唯我独甜
2楼-- · 2019-05-26 07:35

I think you have to solutions.

  1. Just add the beanstalk-maven-plugin definition to your regular pom.xml. The configuration can be stored in separate properties file or provided via system properties in command line (-D option). Add beanstalk goal to command line of maven in Jenkins. So, each build will be deployed on beanstalk. Alternatively you can define yet another project in Jenkins that just runs the deployment without compilation. You can run this deployment project on scheduled basis or via projects dependencies in Jankins.
  2. Create yet another maven project. It will just run beanstalk plugin. I personally do not see serious advantages to do this.
查看更多
Fickle 薄情
3楼-- · 2019-05-26 07:44

I think about three things:

a. I'm not sure (I'm admit I was a bit busy trying to come up with 0.2.7-RC7), but I think the Elastic Beanstalk Configuration Files are supported in Java.

So it perhaps could be a good idea to separate (I admit managing config in Beanstalker is Boring)

b. Another option is using war overlays in maven-war-plugin's overlay feature, and create a war which depends on your other war.

In my personal case, if you ask, I do have a separate deployment profile in Maven, and that feature often come in handy

查看更多
登录 后发表回答