Maven 2 - more than a build tool

Post on 28-Oct-2014

997 views 1 download

Tags:

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

Maven - more than a build tool

Using Maven for automated configuration management and deployment

Harald SøvikSr. Knowledge Engineer, Computas AS

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

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

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

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

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.

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

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

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

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>

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>

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

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

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>

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

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

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

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

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

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

Agenda

Goal and objectives

Infrastructure Configure the AS Deploy to AS Manage AS lifecycle

Drawbacks

Future

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

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

Summary

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

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

For More Information

hso@computas.com http://www.computas.com

Harald Søvikhso@computas.com

Maven – more than a build tool

Using Maven for automated configuration management and deployment