35
Maven and Stack Starter Maven and Stack Starter Michael Youngstrom

Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Embed Size (px)

Citation preview

Page 1: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Maven and Stack StarterMaven and Stack StarterMichael Youngstrom

Page 2: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Understand Maven configuration in “Stack Project”

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

Page 4: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Review

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

Page 5: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Lab 1: Useful Plugins

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

s

Page 15: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Lab 2: Stack Master

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

Page 22: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Modules in Stack Starter

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

Page 24: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

API Module

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

training

Page 33: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Demo

Stack Starter Maven Config Tour

Page 34: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

Lab 3: Maven Profiles

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

Page 35: Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack

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