maven and jelly
Download
Skip this Video
Download Presentation
Maven and Jelly

Loading in 2 Seconds...

play fullscreen
1 / 32

Maven and Jelly - PowerPoint PPT Presentation


  • 131 Views
  • Uploaded on

Maven and Jelly. James Strachan. Introduction. Maven and Jelly are both Apache projects at Jakarta http://jakarta.apache.org Ultimately both will be top level projects inside Jakarta Right now Maven is inside Turbine and Jelly is inside Commons. Topics of Discussion. What is Maven

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Maven and Jelly' - wynona


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
maven and jelly

Maven and Jelly

James Strachan

introduction
Introduction
  • Maven and Jelly are both Apache projects at Jakarta
  • http://jakarta.apache.org
  • Ultimately both will be top level projects inside Jakarta
  • Right now Maven is inside Turbine and Jelly is inside Commons
topics of discussion
Topics of Discussion
  • What is Maven
  • What is Jelly
  • Should we use these things?
  • How, what, why, when…
maven
Maven
  • http://jakarta.apache.org/turbine/maven/
  • It’s a Java project management and comprehension tool
  • Think a layer above Ant
  • Avoid us all hacking Ant build files
build history
Build history
  • First there was make. But was not cross platform.
  • Ant came along as a Java-centric build system that was cross platform
  • We now spend lots of time hacking Ant’s build.xml files
itches maven scratches
Itches Maven Scratches
  • We should be able to share build.xml files
  • Often not much changes from project to project, other that the dependencies (classpath).
  • Maintaining real version information and setting the classpaths are a PITA
early maven
Early Maven…
  • In the early days, Maven used Ant
  • We shared Ant build scripts.
  • Customization was through Ant callbacks.
  • Worked OK, was slow but callbacks suck
maven b5 onwards
Maven b5 onwards…
  • Along comes Jelly…
  • A more flexible front end to Ant.
  • Uses a goal library for Jelly which allow pre/post actions to be registered or goals to be replaced.
  • Goal library is a neat replacement for hacky Ant callbacks.
so how does maven work
So how does Maven work?
  • You create a project.xml which describes your project
    • Project info (name, company, website etc)
    • Where the source code is
    • Where the unit test cases are
    • What the dependencies are
slide10
Then…
  • From the command line type

maven -g

  • To see all the possible goals

maven site:deploy

  • Will build all your code and website
    • run your unit test cases, create a report, javadoc, source code cross reference, CVS log, file activity…
example project xml
Example project.xml

<project>

<id>foo<id>

<dependencies>

<dependency>

<id>log4j</id>

<version>2.1.0</version>

<dependency>

<dependencies>

</project>

what actually happens
What actually happens…
  • project.xml is used to create a POM (Project Object Model)
  • Its reusing Ant tasks under the covers
  • We are sharing (something like) build.xml documents across projects
  • A Jar repository is used to automatically download required jars and to set the classpath
  • All dependency information is automatically documented. It can be embedded into jar manifests too.
maven repository
Maven Repository
  • A local repository and a list of remote repositories.
  • Supports mirroring and N-tier of repositories
  • New jars can be download
  • Repository can be shared across projects
  • Can be used for multi-version testing
what actually happens1
What actually happens…
  • Its just reusing Ant tasks under the covers
  • We are sharing (something like) build.xml documents across projects
  • A Jar repository is used to automatically set the classpath
  • All dependency information is documented. It can be embedded into jar manifests too.
plugins
Plugins…
  • Maven is built around a plugin architecture
  • There’s already a lot of plugins. Type ‘maven –g’ and you’ll see.
  • The plugins are gonna grow and grow.
  • Plugins use the same repository, so no need to worry about setting classpaths…
  • As soon as a new plugin is written, we all get to use it, without hacking build.xml
some plugins
Some plugins…
  • site:deploy – builds and deploys your entire developer website
  • dist:deploy – builds and deploys your distributions
  • test – runs your unit tests
  • test:single-test –Dtestcase=Foo
  • test:ui – runs the Swing JUnit TestRunner
  • Many others…
    • Eclipse plugin, Clover, WAR, EAR, JDiff, CVS log, project metrics, JDepend etc.
so main benefits of maven
So main benefits of Maven
  • No more classpath blues when building
  • We are sharing (something like) build.xml documents across all projects
  • Real dependencies are documented and managed
  • We all get to share plugins added to Maven
maven reactor
Maven Reactor
  • Building lots of projects with interdependencies
  • Like Gump (http://jakarta.apache.org/gump)
  • Can be used for Continuous Integration, running combinations of versions of multiple projects.
  • Using workflow of builds, distributed across servers
  • Builds, runs test cases and creates reports
continuous integration
Continuous Integration
  • Early warning system when things break due to
    • Code changes
    • Different platforms (OS, JDK)
    • Different dependencies (e.g. change to XML parser or other dependent library)
  • We could reuse this infrastructure for doing integration testing across versions, platforms and different dependency sets.
customizing maven
Customizing Maven
  • Create project.properties, or local build.properties, or ~/build.properties
  • Write a plugin
  • Create maven.xml
maven xml
Maven.xml
  • plugin.xml, project.xml and maven.xml are all Jelly scripts.
  • Can use POM beans like ${pom.build.sourceDirectory}

<j:forEach var=“d” items=“${pom.dependencies}”/>

<copy file=“${d.jar}” todir=“${foo}”/>

</j:forEach>

its jelly time
Its Jelly time…
  • Java & XML based processing engine.
  • Superset of Ant build.xml language and JSTL
  • Allows mix and match of declarative and procedural XML languages.
  • Can include other XML languages like BPML, BPEL4WS, WSCI, WSDL invocations etc.
  • Turns any XML document into a ‘script’ that can be ran
pluggable languages
Pluggable languages
  • Pluggable expression languages like JSP EL, Velocity, XPath etc.
  • Pluggable scripting languages, beanshell, JavaScript, Jython.
  • You can plug in your own XML languages or custom beans
features
Features
  • Simple and lightweight
    • Can be ran from command line, used in Maven, in applet, application server etc.
  • Open and extensible
  • XML Namespace URIs can be bound onto a Jelly Library
    • An XML tag name can be bound onto Java code via a Tag
  • Expressions can be used within the XML
based on xml
Based on XML
  • Jelly scripts are parsed from SAX.
    • Can use HTML parser to use non-well formed Jelly scripts.
  • Jelly is based on an XML pipeline architecture.
  • A Tag can consume, emit, filter or transform the XML events of its body.
  • Very powerful, flexible scripting and XML processing engine
  • Ideal for processing XML, SOAP, Web Services etc.
bean example
Bean example…

<price>${customer.orders.calculatePrice()}</price>

<j:if test=“${message.header.foo = ‘abc’}>

</j:if>

<j:forEach var=“order” items=“${bean.orders(‘uk’, foo)}”>

<productOrder id=“${order.id}”>

<amt>${order.amount}</amt>

</productOrder>

</j:forEach>

xml example
XML example…

<x:forEach select=“$doc//food[@kind=‘cheese’]”>

<x:if test=“bar = ‘abc’”>

do something…

</x:if>

<foo>

<x:expr select=“pizza[@topping]”/>

</foo>

</x:forEach>

sql example
SQL example…

<sql:query var=“results”>

select * from customer

</sql:query>

<j:forEach var=“cust” items=“${results.rowsByIndex}>

<customer id=“${cust.id}”>

<name>${cust.name}</name>

</customer>

</j:forEach>

features1
Features
  • Can write tag macros in Jelly script or bind tags to beans
  • Very flexible. E.g. can be used to implement
    • JSTL, page templating system etc.
    • Maven build system
    • workflow languages
    • declarative integration scripts (WIS etc)
jellyunit
JellyUnit
  • Uses Jelly script to implement unit testing
  • Can mix and match beans, SQL, JMS, XML validation, XPath evaluation, SOAP calls, HTTP etc.
jellyunit example
JellyUnit example

<test:case name=“someTest“>

<test:assert test=“${bean.xyz == ‘abc’”/>

<x:parse var=“doc“xml=“foo.xml”/>

<test:assert xpath=“$doc/foo/bar”>

Found the bar!

</test:assert>

</test:case>

summary
Summary
  • Maven is a great tool for managing and building projects
  • Increasingly Maven’s project based Continuous Integration and build/test workflow abilities will be invaluable
  • Jelly can be very useful in both unit and integration testing
ad