mtat.03.229 enterprise system integration · mtat.03.229 enterprise system integration lecture 2b:...
TRANSCRIPT
MTAT.03.229 Enterprise System Integration
Lecture 2b: Deployment to the Cloud Luciano García-Bañuelos University of Tartu
20 minutes introduction to Maven
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 1
Building tools for Java • Ant: a scripAng interpreter, build-‐oriented DSL
• Maven: a standard build workflow executor
◦ ���POM: Project Object Model ◦ Project structure, language, packaging ◦ Dependencies ◦ Other metadata (license, developers, mailing list, etc...)
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 2
Procedural: How to do it !
DeclaraAve: What to do !
Maven: Features • Simple project setup following best pracAces
• Dependency management ◦ ArAfact repositories ◦ Version management ◦ AutomaAc updates
• Release management
• MulA-‐module builds
• Consistent project structure • Consistent build model
• Plugin oriented • Project generated sites
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 3
Setting up Maven
• Set the environment variable M2HOME ◦ export M2_HOME=/usr/local/apache-‐maven/apache-‐maven-‐3.1.0
• Set also the variable PATH ◦ export PATH=$PATH:$M2_HOME/bin
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 4
Lifecycle, plugins, goals • A lifecycle consists of a sequence of phases
• Each plugin provides a set of goals to be executed at specific phases
• Goals: ◦ can be executed manually, or
◦ afached to phases, and executed as part of a sequence of phases
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 5
Deploy
Install
Verify
Integra4on-‐test
Package
Test
Compile
Validate
Surefire
test
Glassfish
create-‐domain start-‐domain
deploy redeploy undeploy
stop-‐domain delete-‐domain
Pre-‐integraAon-‐test
Post-‐integraAon-‐test
Elements within pom.xml
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 6
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 ..."> <modelVersion>4.0.0</modelVersion> <groupId>ee.ut</groupId> <artifactId>Demo</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>Demo</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>
Repositories
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 7
ProjectA
pom.xml
hfp://www.maven.org
ProjectB
pom.xml
$HOME/.m2
LibA LibB LibC
Download
Transitive dependencies
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 8
Project A
A 1.0 B 1.0 C 1.0
D 1.0 E 1.0
F 1.0 G 1.0
F 2.0
20 minutes introduction to Git
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 9
Version control systems • Version control (a.k.a., revision control or source control) is all about managing mulAple versions of documents, programs, web sites, etc. ◦ Almost all “real” projects use some kind of version control
◦ EssenAal for team projects, but also very useful for individual projects
• Some well-‐known version control systems are CVS, Subversion, Mercurial, and Git
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 10
Setting up Git
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 11
Centralized vs. Distributed
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 12
File
CheckoutVersion Database
Version 3
Version 2
Version 1
Central VCS ServerComputer A
File
Checkout
Computer B
Version Database
Version 3
Version 2
Version 1
Server Computer
File
Computer A
Version Database
Version 3
Version 2
Version 1
File
Computer B
Version Database
Version 3
Version 2
Version 1
Git change management
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 13
#include<stdio.h>
int main(void) { printf("Hello\n"); return 0;}
This is Scott's Hello project.
Licensed under GPL.
README.txt hello.c
CommitA
c3d README.txtf13 hello.c
This is Scott's Hello project.
Licensed under GPL.
c3d
#include<stdio.h>
int main(void) { printf("Hello\n"); return 0;}
f13
#include<stdio.h>
int main(void) { printf("Hola\n"); return 0;}
This is Scott's Hello project.
Licensed under GPL.
README.txt hello.c
CommitA
c3d README.txtf13 hello.c
This is Scott's Hello project.
Licensed under GPL.
c3d
#include<stdio.h>
int main(void) { printf("Hello\n"); return 0;}
f13
#include<stdio.h>
int main(void) { printf("Hola\n"); return 0;}
6d4
CommitB
c3d README.txt6d4 hello.c
Basic usage • Clone an exiAng project
• Set up a GIT project locally
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 14
git clone hfps://github.com/heroku/devcenter-‐spring-‐mvc-‐hibernate.git
git init
Basic usage
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 15
Edit files vim, emacs, etc.
Stage the changes git add (file)
Review your changes git status / git diff
Commit the changes git commit
Branching and merging
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 16
98ca9
master
HEAD $ git branch i18n!
i18n
$ git branch!* master! i18n!
$ git checkout i18n!
HEAD
Branching and merging
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 17
98ca9
master
$ git commit!
$ git checkout i18n!
i18n
HEAD
a23fe
i18n
HEAD
$ git commit!
3acd1
i18n
HEAD
Branching and merging
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 18
98ca9
master
$ git checkout -b iss53 master!
iss53
HEAD
a23fe
$ git checkout master!
$ git branch iss53!
3acd1
i18n
HEAD
Branching and merging
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 19
98ca9
master
iss53
HEAD
a23fe 3acd1
i18n
34ac2
iss53
HEAD
$ git commit!
f30ab
iss53
HEAD
Branching and merging
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 20
98ca9
master
a23fe 3acd1
i18n
34ac2
$ git checkout master!
f30ab
iss53
HEAD HEAD
Branching and merging
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 21
98ca9
a23fe 3acd1
i18n
34ac2 f30ab
iss53 master
HEAD
$ git merge i18n!
Two cases: • No conflict, straighporward! • Conflicts, use a conflict resoluAon tool
master
HEAD $ git merge iss553!
b361a
master
HEAD
Working with remote repositories
• Use git clone to replicate repository ◦ You usually have to set up your credenAals
• Get changes with ◦ git fetch ◦ git pull (fetches and merges)
• Propagate changes with ◦ git push!
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 22
$ git config --global user.name "..."!$ git config --global user.email "..."!
Remote branching
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 23
Remote branching
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 24
• Remote branching ◦ Branches on remote are different from local branches
◦ Use git fetch origin to get remote changes
◦ Use git pull origin try to fetch remote changes and merge them onto our current local copy
• To propagate changes to a remote repository, e.g. rname, on a named branch, e.g., bname ◦ Use git push rname bname
Acknowledgements • My presentaAon uses material from
◦ Scof Chacon, IntroducAon to Git hfp://www.youtube.com/watch?v=ZDR433b0HJY
◦ Nate Aune, Deploy Python apps in 5 minutes with PaaS hfp://www.youtube.com/watch?v=eJcFsaVu8HI
DEPLOYMENT TO THE CLOUD LUCIANO GARCÍA-‐BAÑUELOS 25