I am new to Maven and wanted to automate some build steps by automatically deploying several files and folders to the production environment:
my-app-0.7.0-jar-with-dependencies.jar (main application file)
conf.properties (configuration file that can be edited on the fly)
files_folder (folder that contains html, css etc. that can be edited on the fly)
My project structure look like this:
src
main
java
resources (contains resources that should be included in the .jar)
conf.properties.jar
files_folder
.
I started by adding <resources>
element in the pom.xml
<resources>
<resource>
<directory>.</directory>
<includes>
<include>conf.properties</include>
<include>files_folder/**/*.*</include>
</includes>
<targetPath>..</targetPath>
</resource>
</resources>
This moves conf.properties
and files_folder
to the target
directory and this is fine (I can copy .jar, conf.properties and files_folder and run them).
However these files are not moved to the local repository in C:\\Users\\my_name\\.m2\\...
or external repositories (in install and deploy phases).
My thinking is that these resource should be moved to the repositories because:
So the main questions are:
Like other response I'd suggest you need to look at a continuous integration approach. I have had good experience working with Jenkins before. It's free, and comes with a lot of functionatlity. It also has a large community that have developed a range of plugins:
https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins
Depending on what you're deploying and how you want to deploy it some plugins that may be helpful to your process are:
Instead of keeping this files in the classpath, you can keep these files at src/main/resources/META-INF. So when you build your project using maven and if you have chosen the packaging as ear <artifactId>ProjectName</artifactId> <version>Version</version> <packaging>ear</packaging>
then all these files will be packaged inside the jar and will be available in your maven repository
Maven is a build tool and not a deployment tool. For deployment to environments like Test, Q&A or Prod other tools are more suitable like Chef, Puppet or may be a simply shell script etc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.