michael youngstrom
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 PresentationTRANSCRIPT
![Page 1: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/1.jpg)
Maven and Stack StarterMaven and Stack StarterMichael Youngstrom
![Page 2: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/2.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/3.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/4.jpg)
Review
• Maven Plugin Execution• Maven Plugin Configuration• Maven Properties• Maven Plugin Configuration with Properties• Maven Profiles
![Page 5: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/5.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/6.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/7.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/8.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/9.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/10.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/11.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/12.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/13.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/14.jpg)
Lab 1: Useful Plugins
https://tech.lds.org/wiki/Maven_and_Stack_Starter#Lab_1_Useful_Plugin
s
![Page 15: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/15.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/16.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/17.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/18.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/19.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/20.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/21.jpg)
Lab 2: Stack Master
https://tech.lds.org/wiki/Maven_and_Stack_Starter#Lab_2_Stack_Master
![Page 22: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/22.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/23.jpg)
Modules in Stack Starter
• Multi Module project– parent– web– ear (Websphere)– deploy– wam– qa– db– api
![Page 24: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/24.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/25.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/26.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/27.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/28.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/29.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/30.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/31.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/32.jpg)
API Module
• Created when using Web Service template• We’ll cover api more when doing Web Service
training
![Page 33: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/33.jpg)
Demo
Stack Starter Maven Config Tour
![Page 34: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/34.jpg)
Lab 3: Maven Profiles
https://tech.lds.org/wiki/Maven_and_Stack_Starter#Lab_3_Stack_Starter
![Page 35: Michael Youngstrom](https://reader036.vdocument.in/reader036/viewer/2022062407/56812deb550346895d93494c/html5/thumbnails/35.jpg)
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