Maven 2 - more than a build tool

21
Maven - more than a build tool Using Maven for automated configuration management and deployment Harald Søvik Sr. Knowledge Engineer, Computas AS

description

Maven is basically a system for compiling code, packing code and publishing packed code, but the flexibility of plugins allows it to carry out a wide selection of tasks. Most often, these tasks are very developer-centric, assisting in the development- and deployment process. We have successfully implemented a plugin that extend the build system to also handle configuration management of various test-environments, nightly deployment of new versions from CI with a single parameter and easy, centrally controlled configuration of developers environments. Even though the implementation is bound to our choice of infrastructure, the ideas and experiences should apply to a wide range of configurations.

Transcript of Maven 2 - more than a build tool

Page 1: Maven 2 - more than a build tool

Maven - more than a build tool

Using Maven for automated configuration management and deployment

Harald SøvikSr. Knowledge Engineer, Computas AS

Page 2: Maven 2 - more than a build tool

22009 CommunityOne Conference: North | no.sun.com/communityone

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

Page 3: Maven 2 - more than a build tool

32009 CommunityOne Conference: North | no.sun.com/communityone

Pragma:

“The software” is code and build code

checked out from your VCS

that can be assembled

in a repeatable manner

and deployed to an application server

Page 4: Maven 2 - more than a build tool

42009 CommunityOne Conference: North | no.sun.com/communityone

Strategical goal:

Automate manual, labourous tasks to reduce time spent on non-productive work in a software development project.

Tactical goal:

Automate configuration management of a system installation on a remote or local host.

Automate deployment of any version of the software to a defined envionment.

Automate the life cycle of application servers

Page 5: Maven 2 - more than a build tool

52009 CommunityOne Conference: North | no.sun.com/communityone

Objective:

3-tier application: db, ejb-server and client + webserver.

De- and configure a existing JBoss installation. Client installation. No database intervention.

(Could have been installation of baseline datbase, patching with changes, validation of views/procedures/functions)

Multiple software branches: maintenance of production code, development of next major release, maybe a separate branch for a major change (should require no major reconfiguration)

Multiple stageing envrionments: development, test, systems/customer representative test, acceptance test.

Page 6: Maven 2 - more than a build tool

62009 CommunityOne Conference: North | no.sun.com/communityone

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

Page 7: Maven 2 - more than a build tool

72009 CommunityOne Conference: North | no.sun.com/communityone

Step 1: Environmental configuration in build system

Maven POM contains properties and profiles. Profiles lets you select and possibly override a set of properties. And there is always the default profile.

The POM is under version control, and can be modified across branches.

Thus: profiles can correspond to "physical" environments, and let each profile have a set of hosts involved.

VCS

VCSVCSBranch A pom.xmlBranch Aprofile test:- host a- host b

VCSVCSBranch A pom.xmlBranch AVCSVCSBranch A pom.xmlBranch Aprofile test:- ejb host A- web host B

VCSVCSBranch A pom.xmlv3.0

VCSVCSBranch A pom.xmlBranch Aprofile test:- host a- host b

VCSVCSBranch A pom.xmlBranch AVCSVCSBranch A pom.xmlBranch Aprofile test:- ejb host X- web host Y

VCSVCSBranch A pom.xmlv4.0

Page 8: Maven 2 - more than a build tool

82009 CommunityOne Conference: North | no.sun.com/communityone

The default profile: localhost.

<profile> <id>default</id> <properties> <ejbServer>localhost</ejbServer> <webServer>localhost</webServer> <clientHost>localhost</clientHost> <jbossHome>${JBOSS_HOME}</jbossHome> </properties> </profile>

Page 9: Maven 2 - more than a build tool

92009 CommunityOne Conference: North | no.sun.com/communityone

An example profile:

<profile> <id>test</id> <properties> <ejbServer>vm-utst3jb01</ejbServer> <webServer>vm-utst3jbweb01</webServer> <clientHost>ustts02</clientHost> <jbossHome>/usr/local/java/jboss</jbossHome> </properties> </profile>

Page 10: Maven 2 - more than a build tool

102009 CommunityOne Conference: North | no.sun.com/communityone

Runtime configuration

Ad-hoc configuration can be defined run-time:

mvn clean install -Ptest -DejbServer=vm-utst4jb01 -DwebServer=vm-utst2jbweb01

Page 11: Maven 2 - more than a build tool

112009 CommunityOne Conference: North | no.sun.com/communityone

Configuration of ASNow, when the hosts are known, they can be configured.

Remove previous configuration files and unneccessary files (whitelist/blacklist)

Copy libraries and configuration files

Each host has a folder in VCS where config and libs are stored as files

Clean the installation. Remove temporary files and serialized data. Remove prevous deployments.

<ejbDeleteFiles> <string> deploy/hsqldb-ds.xml </string> <string> conf/jbossmq.xml </string></ejbDeleteFiles>

3.0/ conf/ vm-utv3jb01/ JBoss/ lib/ itext.jar jasper.jar conf/ ojdbc-ds.xml log4j.xml

Page 12: Maven 2 - more than a build tool

122009 CommunityOne Conference: North | no.sun.com/communityone

Stop and start the AS invoke the native start/stop script via java runtime

requires some AS-dependent knowledge

automated deployments must work: kill -9 if neccessary.

ssh <host> sudo /etc/init.d/jboss stop// read output stream and assert result// sleepssh <host> ps -ef// read output and check status// possibly:ssh <host> kill <pid>ssh <host> kill -9 <pid>

Page 13: Maven 2 - more than a build tool

132009 CommunityOne Conference: North | no.sun.com/communityone

Deployment copy the application file to the application server

locally, you can use java.io

scp to a remote server (but requires stuff beyond maven)

optionally

scp in java integrate with AS hot deploy

Page 14: Maven 2 - more than a build tool

142009 CommunityOne Conference: North | no.sun.com/communityone

CI lifecycle

Update from ci <scheduled> Build, package Stop the AS

Clean, configure

Deploy to ASStart the ASDeploy client

Assert status

Page 15: Maven 2 - more than a build tool

152009 CommunityOne Conference: North | no.sun.com/communityone

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

Page 16: Maven 2 - more than a build tool

162009 CommunityOne Conference: North | no.sun.com/communityone

Drawbacks:

developers become oblivious to AS configuration/deployment

very generic - has few shortcuts

somewhat time consuming, but good for CI

already implemented by i.e. oracle grid control

Page 17: Maven 2 - more than a build tool

172009 CommunityOne Conference: North | no.sun.com/communityone

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

Page 18: Maven 2 - more than a build tool

182009 CommunityOne Conference: North | no.sun.com/communityone

Future: short term

use in other projects

make available as open source

doc

remove dependencies on external tools

long term

must support multiple arcitectures

must support multiple application servers

Page 19: Maven 2 - more than a build tool

192009 CommunityOne Conference: North | no.sun.com/communityone

Summary

Simple, tool for configuration management Easy to implement new requirements Quick tool for developers

Page 20: Maven 2 - more than a build tool

202009 CommunityOne Conference: North | no.sun.com/communityone

For More Information

[email protected] http://www.computas.com

Page 21: Maven 2 - more than a build tool

Harald Sø[email protected]

Maven – more than a build tool

Using Maven for automated configuration management and deployment