39
26.06.2002 DI Siegfried GÖSCHL [email protected] The The Stairway Stairway to to Maven Maven The The JAKARTA Project JAKARTA Project Build Build And And Comprehension Comprehension Tool Tool

The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

  • Upload
    others

  • View
    25

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

26.06.2002

DI Siegfried GÖ[email protected]

TheThe StairwayStairway to to MavenMaven

TheThe JAKARTA Project JAKARTA Project BuildBuildAnd And ComprehensionComprehension ToolTool

Page 2: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

2 2Stairway To Maven

The Problem

How do you build and maintain complex softwareprojects written in Java?!

§ The Chinese Approach ...– You can always find a student or two for the build

§ Make or better not to Make – that‘s the question ...– Ever tried to run a UNIX makefile on Windows?!

§ All ANTs are equal and some are even more equal ...– Tired of copy/pasting ANT scripts?!– Need something like ANT with more bells and whistles?!

Page 3: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

3 3Stairway To Maven

Maven For Rookies

§ Maven was initiallydeveloped for buidingTurbine

§ Maven matured into an open source softwareengineering platform

§ The core functionality isautomated projectbuilding, distribution and project website creation

§ A project is described witha XML Project ObjectModel (POM)

§ The POM defines how to build a project and definesthe external dependencies

§ The project build resultare created in the localrepository

§ Dependent JARs aredownloaded from a remoterepository

§ The Maven functionality isimplemented in terms of plugins

§ The plugins are written in Jelly

Page 4: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

4 4Stairway To Maven

What is in the Maven Box?!

Page 5: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

5 5Stairway To Maven

Under The Hood

Project Object Model (POM)Project Object Model (POM)

§ Verbose project description§ Company information§ List of developer and their roles§ Mailing list and CVS server access§ Source code and unit test code location§ Resources needed for a build§ Definition of JAR dependencies§ Assembling of artifacts, e.g. JAR

Page 6: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

6 6Stairway To Maven

The Core Plugins

§ The distribution plugin allows building a binary or a source distribution from the command line

§ An ANTANT build file can be generated and distributed to allow ANTANT users to build the distribution

§ Other plugins allows– Creating a JAR file– Creating a WAR file– Creating an EAR file– Deploying the distribution automatically

Build PluginsBuild Plugins

No more thrillsbuilding your project!

Page 7: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

7 7Stairway To Maven

The Core Plugins

§ Site creation based on Project Object Model§ Site generation uses XDOC

– Maven generated XDOC– Manually written documentation

§ JSTL transforms XDOC into HTML§ Site layout is defined through xdocxdoc//navigation.xmlnavigation.xml§ Site appearance is customizable through properties

defined in project.propertiesproject.properties

Site PluginSite Plugin

Page 8: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

8 8Stairway To Maven

The Core Plugins

Site PluginSite Plugin

Page 9: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

9 9Stairway To Maven

The Core Plugins

Site PluginSite Plugin

Page 10: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

10 10Stairway To Maven

The Core Plugins

§ Various coding styles can be defined– Sun coding convention– Turbine coding convention– Roll your own coding convention (if you really have to)

§ Rules are customizable through XML file– Maximum line length of 100 instead of 80 characters– Patterns for constants and variables– Setting a different tab width

CheckStyle PluginCheckStyle Plugin

Just in case youhave a coding convention ...

Page 11: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

11 11Stairway To Maven

The Core Plugins

CheckStyle PluginCheckStyle Plugin

Page 12: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

12 12Stairway To Maven

The Core Plugins

§ Plugin accesses CVS directly to extract developmentactivity information

§ Extracts information about– Changes and commits– Number of commits per developer– Number of changes for a file

§ Ongoing work to support VSS and ClearCase

Activity PluginActivity Plugin

No more diggingthrough CVSchangelog

Page 13: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

13 13Stairway To Maven

The Core Plugins

Activity PluginActivity Plugin

Page 14: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

14 14Stairway To Maven

The Core Plugins

§ Runs JUNIT test case§ The plugin creates a XDOCXDOC report§ The XDOCXDOC report is then transformed to HTML§ The JUNITJUNIT test report is then integrated within the

generated project site

Test PluginTest Plugin

I hope youhave some tests?!

Page 15: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

15 15Stairway To Maven

The Core Plugins

Test PluginTest Plugin

Page 16: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

16 16Stairway To Maven

The Core Plugins

§ Is using JDependJDepend from ClarkWare§ Analyzes class files§ Reports package dependencies§ Finds cyclic dependencies§ Generates a HTML report to be included into project

website

JDepend PluginJDepend Plugin

Page 17: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

17 17Stairway To Maven

The Core Plugins

JDepend PluginJDepend Plugin

Page 18: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

18 18Stairway To Maven

The Core Plugins

§ Transforms source files into HTML files§ Provides syntax coloring and hypertext linking§ Allows linking between reports and actual source

code as done with– CheckStyle plugin– PMD plugin

Java Cross Reference PluginJava Cross Reference Plugin

Page 19: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

19 19Stairway To Maven

The Core Plugins

Java Cross Reference PluginJava Cross Reference Plugin

Page 20: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

20 20Stairway To Maven

The Core Plugins

JavaDoc PluginJavaDoc Plugin

Page 21: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

21 21Stairway To Maven

The Core Plugins

PMD PluginPMD Plugin

Page 22: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

22 22Stairway To Maven

The Core Plugins

§§ PMDPMD is a static source code analyzer§§ PMDPMD is rule driven

– Basic rules– Import rules– Unused code rules– Naming rules– Design rules

§ The plugin creates an HTML report with linking to theSource Cross Reference

PMD PluginPMD Plugin

Page 23: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

23 23Stairway To Maven

Custom Plugins

§ Maven currently comes with more than 70 plugins§ For additional functionality

– Check out SourceForge and Google– Write your own plugin and contribute it ...

§ Some plugins can‘t be shipped with Maven due to incompatible licences–– CLOVERCLOVER Code Coverage Analyzer–– SIMIAN SIMIAN Code Similarity Analyzer–– CanooCanoo WebTestWebTest Functional WebTesting Tools

Page 24: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

24 24Stairway To Maven

Custom Plugins

§ Commercial software from TheThe CortexCortex§ Instruments the JUNITJUNIT test case code§ Generates a HTML test coverage report

– Conditional Coverage– Statement Coverage– Method Coverage

§ Integrated into generated project site through Maven

Clover Test Coverage PluginClover Test Coverage Plugin

Another good reason for unit tests !!

Page 25: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

25 25Stairway To Maven

Custom Plugins

Clover Test Coverage PluginClover Test Coverage Plugin

Page 26: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

26 26Stairway To Maven

Custom Plugins

Clover Test Coverage PluginClover Test Coverage Plugin

Page 27: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

27 27Stairway To Maven

Custom Plugins

§ Commercial tool from RedhillRedhill ConsultingConsulting§ Code Similiarity Anaylzer§ Generates a HTML report§ Integrated into generated project site through Maven

Simian PluginSimian Plugin

Page 28: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

28 28Stairway To Maven

Custom Plugins

Simian PluginSimian Plugin

Page 29: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

29 29Stairway To Maven

Custom Plugins

§ Open Source Project from Canoo Engineering AG§ Automates functional testing of webapps§ Test scripts are written in XML

– Can be done by test engineers

§ Integration in den Daily Build with ANT or Maven§ Maven integration comes with full reporting

Canoo WebTest PluginCanoo WebTest Plugin

No more excuses for skipping tests ...

Page 30: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

30 30Stairway To Maven

Custom Plugins

Canoo WebTest PluginCanoo WebTest Plugin

Page 31: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

31 31Stairway To Maven

Custom Plugins

Canoo WebTest PluginCanoo WebTest Plugin

Page 32: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

32 32Stairway To Maven

Real Life Maven

§ Provide XDOCXDOC for developer documentation– Simple XML-based documentation– Can be transformed into HTML and PDF

§ Simplified DOCBOOKDOCBOOK for technical documents– Transformation to PDF using DOCBOOK plugin

§ Stick to your existing WORDWORD documents– The Word2HTML plugin converts WORD documents to

HTML automatically

How to Write Documentation ...How to Write Documentation ...

Page 33: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

33 33Stairway To Maven

Real Life Maven

§ POM Inheritance Mechanism to simplify mavenizingmavenizingmultiple projects– Define common properties in the master POM– Add or override project specific properties

§ Multiproject Plugin– Plugin triggers build of all dependent projects– Auto-detection of the required build order

Multi-Project SupportMulti-Project Support

Page 34: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

34 34Stairway To Maven

Real Life Maven

§ Maven can do in 0 lines what ANT takes 50 lines fora simple project

§ You can reuse ANT tasks in Maven– Calling ANT tasks directly from JELLY– Start a JVM running an ANT script

§ You can start MAVEN from an ANT script– Retrofitting MAVEN into an existing ANT build

§ You can always roll your own plugin– Enhydra XMLC plugin– Canoo Webtest plugin

Breaking the Ant AddictionBreaking the Ant Addiction

Page 35: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

35 35Stairway To Maven

Real Life Maven

§ Incompatible directory structure?!– Maven can be tweaked to use a different directory layout– Could break plugins ...

§ More than one source directories per project?!– Split the project into subprojects– Copy the source code in a <preGoal>– Add the additional classpath in a <preGoal>

§ More than one artifact per project?!– Use multiple targets to create your artifacts– Register <preGoals> or <postGoals> to do the work

The Maven ProblemsThe Maven Problems

Page 36: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

36 36Stairway To Maven

Real Life Maven

§ We don‘t use version numbers for JARs?!– Why is it good enough for third-party libraries?!– You can always circumvent a missing version number using

a constant, e.g. „LATEST“

§ Can we resurrect our existing ANT scripts?!– Some ANT scripts are made obsolet by Maven– Maven provides a ANT taglib calling the ANT tasks directly

§ Will Maven be legacy?!– Maven was resently promoted to a top-level APACHE

project such as ANT, Apache Webserver or Cocoon

§ Is Maven good enough for serious projects?!– Check out the „Powered By Maven“

The Maven ProblemsThe Maven Problems

Page 37: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

37 37Stairway To Maven

Conclusion

§§ MavenMaven is an Open Source project build and comprehension tool developed by the JAKARTAJAKARTAcommunity

§§ MavenMaven is an integration platform for softwareengineering tools using a plug-in mechanism

§§ MavenMaven provides a remote and local JAR repository to simplify upgrading of JARs

§§ MavenMaven could be the answer to a lot of your softwareengineering problems

Page 38: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

38 38Stairway To Maven

The End

Any questions !?

Page 39: The Stairway to Maven - The Apache Software Foundationpeople.apache.org/~sgoeschl/presentations/maven-20020626.pdf · 2007-09-14 · Stairway To Maven 3 Maven For Rookies § Maven

39 39Stairway To Maven

Related Links

http://www.redhillconsulting.com.au/products/simian/SIMIANSIMIAN

http://jakarta.apache.org/ant/index.htmlANTANT

http://maven-plugins.sourceforge.netMaven PlugMaven Plug--insins

http://jakarta.apache.org/commons/sandbox/jelly/JellyJelly

http://www.clarkware.com/software/JDepend.htmlJDependJDepend

http://www.thecortex.net/clover/CloverClover

http://jakarta.apache.org/turbine/index.htmlTurbineTurbine

http://pmd.sourceforge.net/PMDPMD

http://www.kclee.com/clemens/java/javancss/JavaNCSSJavaNCSS

http://jakarta.apache.org/turbine/maven/MavenMaven