Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
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 Useful Maven Plugins Stack Master Review Stack Starter Stack Starter Template – Template Modules Review • • • • • Maven Plugin Execution Maven Plugin Configuration Maven Properties Maven Plugin Configuration with Properties Maven Profiles 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 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 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 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 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 Useful 3rd Party Plugins (Build) • GWT Plugin – Compiles a GWT application – Runs GWTTestCases • JSPC Plugin – Compiles .jsp files – Useful for finding syntax errors 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 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 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 Lab 1: Useful Plugins https://tech.lds.org/wiki/Maven_and_Stack_Starte r#Lab_1_Useful_Plugins 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 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 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> Discovering Managed Dependencies • Use Tools – CTRL+click on stack-master – Effective POM • View Dependency Management Report – http://code.lds.org/mavensites/stack/modules/master/{Version}/dependency-management.html • View file in local repository • Many more 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 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) Lab 2: Stack Master https://tech.lds.org/wiki/Maven_and_Stack_Starte r#Lab_2_Stack_Master 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 Modules in Stack Starter • Multi Module project – parent – web – ear (Websphere) – deploy – wam – qa – db – api 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 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 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) 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 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 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 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 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 API Module • Created when using Web Service template • We’ll cover api more when doing Web Service training Demo Stack Starter Maven Config Tour Lab 3: Maven Profiles https://tech.lds.org/wiki/Maven_and_Stack_Starte r#Lab_3_Stack_Starter 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