开发者

Create webapp war releases 'the maven way'

my webapp consists in mainly two artifacts, java-server.jar and js-client.war. Both are aggregated/overlayed and get additional property files for the target environment. Finally, i get the war file.

Some war files are deployed using tomcat:deploy some by a script but that shouldn't matter at this point.

There are several things I don't like with my approach:

  • server and client are released with the maven-release-plugin, the final webapp is not.
  • Just by having the final war file I cannot determine for which server it was built.
  • I usually need several client/server combinations at once: While I build the beta server with the stable versions, the nightly build server shall operate on the latest snapshots.

How do you maintain, release and deploy (to maven repo) stable/beta webapps? How do you maintain target-server specific configuration settings? How do you keep different versions? Do you have a lot of branches?

Than开发者_JAVA百科ks, Jan


What I'm doing is using Jenkin's extra maven build steps to execute

tomcat:deploy

after every build. With the right maven profile, that points the builds to our dev server. Then when we want to push to staging, we use the maven release plugin (with Jenkins again) to create a release with a version number that isn't a snapshot. Say we then release 2.0beta3 to staging. This is done with something like:

tomcat:deploy -P staging-deploy

The profile then ensures we push to the staging server instead of the dev server with a pom entry like this:

    <profile>
        <id>deploy-staging</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat-maven-plugin</artifactId>
                    <configuration>
                        <server>tomcat-staging</server>
                        <url>http://tomcat-staging.internal:${tomcat-staging.port}/manager/text</url>
                        <path>${tomcat.path}</path>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

Finally, getting from staging to live is done completely outside maven and jenkins. I just don't trust maven to not break :-)


I can recommend using a build server like hudson. It has maven and rcs support. You can specify for instance what branch of your source code to build and what maven targets to execute.

We also use hudson to deploy builds to our web servers.


My situation isn't as complex as yours, so I can only answer this question:

How do you maintain target-server specific configuration settings?

I try to externalize all configuration so that I'm deploying the exact same WAR file to stage/prod. I use Spring's context:property-placeholder tag for this. There are "default" properties files in the WAR, which are overridden by properties in /etc/app/*.properties (c:/etc/app/*.properties on Windows).

As for actual deployment, I currently upload the WAR file by hand, but plan to automate this in the near future.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜