Maven Structure - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Maven Structure

Description:

At the moment, plug-ins are all Jelly scripts ... Jelly Scripting. XML scripting language that consists enitrely of tag libraries ... – PowerPoint PPT presentation

Number of Views:97
Avg rating:3.0/5.0
Slides: 14
Provided by: blogsCo
Category:
Tags: jelly | maven | structure

less

Transcript and Presenter's Notes

Title: Maven Structure


1
Maven Structure
2
POM The Project Object Model
  • Defines structure of the project
  • Supplies Metadata
  • Has its own context where script variables and
    properties are loaded a form of scope
  • basedir/project.properties and
    basedir/build.properties are loaded into the
    context, as well as defaults and
    /build.properties
  • Both POM properties control build. General
    rule one plugin uses a property, but multiple
    plugins use POM elements

3
Dependencies and the Repository
  • Dependencies can be of any type, but are
    typically JAR files
  • Dependencies are downloaded from a remote
    repository (you can specify multiple), and placed
    in a local (per-user) repository
  • If it is a JAR or EJB dependency, it is added to
    the classpath for build/execution
  • Some dependencies have a special version SNAPSHOT

4
Goals
  • Goals are like ant targets, but more flexible
    attainment tree
  • All goals are defined in plug-ins, where prefix
    generally matches the plugin name.
  • Eg. javacompile ? maven-java-plugin
  • Goals can have prerequesites and hooks (preGoal
    and postGoal)

5
Plug-ins
  • At the moment, plug-ins are all Jelly scripts
  • Each contains goals and hooks that are run every
    time the goal is requested
  • Conditionally enabled by presence of elements in
    the POM or variables/properties in the context
  • Eg. JAXB plugin runs jaxbgenerate before
    javacompile every time. Only does anything if
  • maven.jaxb.schemas is set
  • Any of the above schemas have been changed since
    last build

6
Jelly Scripting
  • XML scripting language that consists enitrely of
    tag libraries
  • Sounds strange, but it is basically an
    implementation of JSP 2.0 and then some.
  • Provides most of JSTL tags, and uses JEXL to do
    the expressions
  • In maven, the default tag library is werkz
    which is used to define goals, but any others can
    be imported per script
  • Maven.xml file in same directory as POM is a
    custom project jelly script

7
Jelly Scripting Example
  • ltproject xmlnsantjellyant xmlnsjjellycore
    gt
  • ltgoal namemy-new-goal prereqsmy-goalgt
  • ltjif testmyPropertyyesgt
  • ltantechogtmyProperty is yeslt/antechogt
  • lt/jifgt
  • lt/goalgt
  • ltgoal namemy-goalgt
  • ltjset varmyProperty valueyes/gt
  • lt/goalgt
  • ltpreGoal namejavacompilegt
  • ltantechogtAbout to compilelt/antechogt
  • lt/preGoalgt
  • ltpostGoal namejavacompilegt
  • ltantechogtFinished compilelt/antechogt
  • lt/postGoalgt
  • lt/projectgt

8
Maven Execution
  • Checks all plugin JARs in MAVEN_HOME/plugins are
    unzipped to /.maven/cache
  • Plugins are loaded from the unzipped plugins
    directory and goals are mapped. The scripts are
    actually executed, so any code outside of a goal
    is also run
  • POM is loaded, with its properties
  • Dependencies are checked for existence,
    downloaded if not in local repository. SNAPSHOT
    dependencies are downloaded again if the remote
    version is newer
  • maven.xml parsed and run to define new goals
  • Goals are found and executed

9
Reactor
  • Reactor is used to run maven over multiple
    projects.
  • Eg ltmavenreactor includesjava//project.xml
    goalsclean,site bannerRebuilding subproject
    site/gt
  • Best used with the multiproject plugin

10
Multiproject
  • Handles multiple different component types
  • Can build an aggregated site and navigation
  • Each project sets maven.multiproject.type
    property to jar, war, install, ear, etc.
  • maven multiprojectinstall-snapshotmaven
    multiprojectdeploy-snapshot

11
Troubleshooting
  • Read the build output see if you notice
    anything unusual (eg files copied/compiled not
    what you expected)
  • Rebuild clean (rm rf target or maven clean will
    do the job)
  • rm rf /.maven/cache
  • Check for conflicting versions in
    MAVEN_HOME/plugins (global plugins) and
    HOME/.maven/plugins (user plugins)
  • If you get an exception, run maven with e and
    report the trace to me or maven-user mailing
    list, or even better look in the maven source. It
    has a bad habit of throwing exceptions when there
    are reportable errors. File this in Maven's JIRA.
  • If you get an error like /cache/maven-java-plugin
    -1.3.113111, look at plugin.jelly in the
    directory given at line 131, column 11. If it
    looks like a Maven bug, file in JIRA.
  • Run maven X to get diagnostics during build
    (like ant debug). Eg outputs filtering
    replacements being made
  • If you are having classpath/dependency problems
    check that the JARs in the local repository were
    downloaded correctly. Look for zero-length files
    in /.maven/repository. As a last resort, you can
    always rm rf /.maven/repository to get them
    again

12
Documentation
  • Xdocs directory contains documentation for a
    project
  • All .xml files are transformed to HTML
  • Section, subsection, and tables treated specially
  • Example next slide

13
Example Document
  • ltdocumentgt
  • ltpropertiesgt
  • ltauthor emailbporter_at_f2network.com.augtBrett
    Porterlt/authorgt
  • lttitlegtSome docolt/titlegt
  • lt/propertiesgt
  • ltbodygt
  • ltsection nameDark blue headinggt
  • ltpgtSome textlt/pgt
  • ltsubsection nameLight gray headinggt
  • ltpgtSome more textlt/pgt
  • lt/subsectiongt
  • ltsourcegtlt!CDATA
  • example source code here
  • gtlt/sourcegt
  • lt/sectiongt
  • lt/bodygt
  • lt/documentgt
Write a Comment
User Comments (0)
About PowerShow.com