michael youngstrom

35
Maven and Stack Starter Maven and Stack Starter Michael Youngstrom

Upload: ocean-peterson

Post on 31-Dec-2015

23 views

Category:

Documents


0 download

DESCRIPTION

Maven and Stack Starter. Michael Youngstrom. Notes. This is a training NOT a presentation Please ask questions Prerequisites Introduction to Java Stack Intermediate Maven Basic Java and XML skillz. Overview. Understand Maven configuration in “Stack Project” Review Intermediate Maven - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Michael Youngstrom

Maven and Stack StarterMaven and Stack StarterMichael Youngstrom

Page 2: Michael Youngstrom

Notes

• This is a training NOT a presentation• Please ask questions• Prerequisites– Introduction to Java Stack– Intermediate Maven– Basic Java and XML skillz

Page 3: Michael Youngstrom

Understand Maven configuration in “Stack Project”

• Review Intermediate Maven• Useful Maven Plugins• Stack Master• Review Stack Starter• Stack Starter Template– Template Modules

Page 4: Michael Youngstrom

Review

• Maven Plugin Execution• Maven Plugin Configuration• Maven Properties• Maven Plugin Configuration with Properties• Maven Profiles

Page 5: Michael Youngstrom

Useful Maven Plugins

• Maven has numerous plugins– Apache Maven Community:• http://maven.apache.org/plugins

– Codehaus Community:• http://mojo.codehaus.org/plugins.html

– LDSTech (Java Stack) Plugins:• http://code.lds.org/maven-sites/stack/

– Not finding what you need? Try searching:• {some product} maven plugin

Page 6: Michael Youngstrom

Useful 1st Party Plugins (Build)

• Java Compiler Plugin– Actually compiles Java code and tests

• Resources Plugin– Processes resources and test-resources

• AntRun Plugin– Executes an embedded Ant script– Useful for quickly hacking a Plugin

• RequireJS Example• Shade Plugin– Generates an Uber-JAR of current project and

dependencies

Page 7: Michael Youngstrom

Useful 1st Party Plugins (Packaging)

• Jar Plugin– Creates a jar file– Specify MANIFEST.MF values

• War Plugin– Packages a web application in to a .war file– Can Merge .war files– Filter web resources

• Ear Plugin– Packages artifacts into an .ear file– Automatically generates application.xml

Page 8: Michael Youngstrom

Useful 1st Party Plugins (Testing)• Surefire is for Unit Testing

– Executes in the “test” phase– Test results are processed after executed– Test file pattern:

• **/*Test.java• **/Test*.java• **/*TestCase.java

• Failsafe is for Integration Testing– Tests execute in the “integration-test” phase– Test results are processed in the “verify” phase– Test file pattern:

• **/IT*.java• **/*IT.java• **/*ITCase.java

• Only supports TestNG or Junit 4 (not both) in same module

Page 9: Michael Youngstrom

Useful 1st Party Plugins (Documentation)

• Javadoc Plugin– Builds and packages project Javadocs

• Source Plugin– Builds and packages source code of project

• Plugin Plugin– Builds Maven Plugins– Builds Reference Documentation

• Site Plugin– Builds Reference site for project

• Javadocs• Browsable Sources (jxr)• Test Results• Maven Docs

Page 10: Michael Youngstrom

Useful 3rd Party Plugins (Build)

• GWT Plugin– Compiles a GWT application– Runs GWTTestCases

• JSPC Plugin– Compiles .jsp files– Useful for finding syntax errors

Page 11: Michael Youngstrom

Useful 3rd Party Plugins (Misc)

• Wagon Plugin– Uploads and Downloads file

• Exec Plugin– Execute a native or Java application

• Webstart Plugin– Numerous WebStart oriented utilities

• Signing• Jnlp file Generation

• TagLib Plugin– Generates JSP Taglib Documentation

Page 12: Michael Youngstrom

LDSTech Plugins (Deploy)

• Tomcat Plugin– Packages a Tomcat “Deployable”– Configure and deploy “Vanilla” Tomcat

• T-Cat Plugin– Deploys to a T-Cat managed instance

• Websphere Plugin– Packages a Webphere “Deployable”– Deploys to Websphere instance using Middleware deploy

scripts• WAM Plugin– Wraps execution of WAM Emulator– Can deploy to remote server– Can execute wam-config packaged in a jar dependency

Page 13: Michael Youngstrom

LDSTech Plugins (Misc)

• DB Migrator Plugin– Helps a team manage DB Schema changes– Packages migrations for future execution– Execute migrations as part of a build

• Pseudo i18n Plugin– Generates pseudo translations of properties files

Page 14: Michael Youngstrom

Lab 1: Useful Plugins

https://tech.lds.org/wiki/Maven_and_Stack_Starter#Lab_1_Useful_Plugin

s

Page 15: Michael Youngstrom

Stack Master

• Organizational Parent POM– The definition of a “Stack Application”

• Configuration Extensions• Manages Dependencies– Doesn’t include only manages

• Manages Plugins– Doesn’t execute only manages

• Extends stack-thirdparty– Implementation Detail

Page 16: Michael Youngstrom

Configuration Extensions

• Support for Binary Resources– /src/main/binary– /src/test/binary

• Resource directory for I18n– /src/main/bundles

• Encoding– UTF-8 Everywhere we can

Page 17: Michael Youngstrom

Dependencies

• Uses Dependency Management– Allows libraries to be upgraded with a “Stack Upgrade”

• Includes all Stack and major thirdparty libraries– Tested and verified to work correctly together

• Provides appropriate exclusions– Java 6– Fixing thirdparty “optional” dependencies

• All dependencies have version property– Allows upgrade or downgrade without redefinition

<properties> <springVersion>3.0.5.RELEASE</springVersion> ...</properties>

Page 18: Michael Youngstrom

Discovering Managed Dependencies

• Use Tools– CTRL+click on stack-master– Effective POM

• View Dependency Management Report– http://code.lds.org/maven-sites/stack/modules/master/{Version}/

dependency-management.html

• View file in local repository• Many more

Page 19: Michael Youngstrom

Plugins

• Specify version of many plugins– Including Dependencies

• Allow us to upgrade plugins with Stack Releases• Some Default configuration and executions• All plugins have a version property

Page 20: Michael Youngstrom

Default Plugin Configuration

• Compiler & JSPC plugin set to Java 6• Add default meta data to MANIFEST.MF– Project Maven Information– Build-Revision– Build-Url– Build-Date– Stack-Version

• FailSafe Plugin– Ignore Test failures by default (independent of Surefire)– Created “itGroups” property (independent of Surefire)

Page 21: Michael Youngstrom

Lab 2: Stack Master

https://tech.lds.org/wiki/Maven_and_Stack_Starter#Lab_2_Stack_Master

Page 22: Michael Youngstrom

Stack Starter Review

• Stack Starter is a templating application• Produces a preconfigured project:– Fully functional– Uses supported tools– Can provides a simple demo

• The generated application is yours to evolve• “Stack” upgrades simply update tool versions not

configuration

Page 23: Michael Youngstrom

Modules in Stack Starter

• Multi Module project– parent– web– ear (Websphere)– deploy– wam– qa– db– api

Page 24: Michael Youngstrom

Parent Module

• Holds most build configuration– Easier to see configuration in one place

• Defines Maven repositories (internal or external)• Prefer using plugin expression configuration– Easier to create profiles– Supports configuration using command line

• The deploy* properties unify deployment config– App Server– WAM– Embedded

Page 25: Michael Youngstrom

Stack Starter Profiles

• Stack Starter uses profiles to represent “usage scenarios”– Deployment Mode (local, embedded, remote)– App Server Config– Test Execusion Config– DB Migration Config– Wam Config

• Dev is the default scenario• Continuous focuses on continuous build config

Page 26: Michael Youngstrom

Web Module

• The heart and soul of a “stack application”• Produces project .war file– Uses maven-war-plugin for .war packaging

• Runs Unit and Integration Tests as part of build– Supports Spring integration testing framework– Only support Junit 3.x and TestNG (No Junit 4)

Page 27: Michael Youngstrom

Deploy Module

• Owns application server configuration• Produces .zip artifact combining config and war(s) or an ear• Tomcat Deploy

– Uses packaging “tomcat-deployable”– Uses stack-tomcat-maven-plugin– Requires 1-* war dependencies– Configuration in /src/main/resources

• Websphere Deploy– Uses packaging “was-deployable”– Uses stack-was-maven-plugin– Requires an ear dependency– Configuration in /src/main/resources

• Will execute a deployment if enabled

Page 28: Michael Youngstrom

Wam Module

• Manages WAM Emulator• Uses stack-wam-maven-plugin– Allows Wam configuration to change based on profile– Simplified launching– Config is in /src/main/resources– Will remote deploy wam emulator if enabled

• Produces jar artifact for wam config reuse– See QA Module

Page 29: Michael Youngstrom

QA Module

• Enables black box in container testing• Executes tests against a running container:– Selenium based UI Tests– Spring based Web Service Tests– Etc

• Produces jar containing tests– Stay Tuned!

• Supports Embedded Deployment

Page 30: Michael Youngstrom

Stack Starter Deployment

• Typically Deployment is out of process– Sometimes requires pre installed Server (Websphere)

• Embedded Deployment is in process– Servers are bound to Maven build process– Allows setup and teardown of Servers as part of module

build• QA module supports Embedded Deployment for

Tomcat– Tomcat and Wam launched in pre-integration-test– Tomcat and Wam terminated in post-integration-test

• Enabled by default in “dev” profile

Page 31: Michael Youngstrom

DB Module

• Manages DB Migration Tool• Uses stack-db-maven-plugin:– packaging type “stack-db-migrator”

• Produces .zip artifact– Capable of executing DB Migrations without Maven

• Will execute db migration in pre-integration-test phase– Enabled by default

Page 32: Michael Youngstrom

API Module

• Created when using Web Service template• We’ll cover api more when doing Web Service

training

Page 33: Michael Youngstrom

Demo

Stack Starter Maven Config Tour

Page 34: Michael Youngstrom

Lab 3: Maven Profiles

https://tech.lds.org/wiki/Maven_and_Stack_Starter#Lab_3_Stack_Starter

Page 35: Michael Youngstrom

Summary

• Maven has a number of useful plugins• Use of Stack Master is the definition of a “Stack

Application”• Stack Starter provides a way to use stack tools– Supports Black Box Testing– Supports remote and embedded deployment