SlideShare a Scribd company logo
Implementing Quality
                         on Java projects




                           Vincent Massol
                           Committer XWiki
                             XWiki SAS

                             @vmassol
                                              27 au 29 mars 2013
Sunday, March 31, 13
Vincent Massol

            • Speaker Bio
               •       CTO XWiki SAS
            • Your Projects
               •       XWiki (community-driven open source project)
               •       Past: Maven, Apache Cargo, Apache Cactus, Pattern Testing
            • Other Credentials:
               •       LesCastCodeurs podcast
               •       Creator of OSSGTP open source group in Paris
               •       3 books: JUnit in Action, Maven: A Developer’s Notebook, BBWM

Sunday, March 31, 13
What is Quality?




Sunday, March 31, 13
The XWiki project in summary
      •      9 years old
      •      28 active
             committers
      •      7 committers
             do 80% of
             work
      •      700K NCLOC
      •      11 commits/
             day
      •      16 mails/day


Sunday, March 31, 13
Examples of Quality actions
            • Coding rules (Checkstyle, ...)    • Ensure API stability
            • Test coverage                     • Code reviews
            • Track bugs                        • License header checks
            • Don’t use Commons Lang 2.x        • Release with Java 6
            • Use SLF4J and don’t draw Log4J/   • Ensure javadoc exist
                   JCL in dependencies
                                                • Prevent JAR hell
            •      Automated build
                                                • Release often (every 2 weeks)
            •      Automated unit tests
                                                • Collaborative design
            •      Stable automated
                                                • Test on supported
                   functional tests               environments (DB & Browsers)
Sunday, March 31, 13
Quality Tip #1

                       API Stability




                                        27 au 29 mars 2013
Sunday, March 31, 13
The Problem



                       Class Not Found or Method Not
                                   Found




Sunday, March 31, 13
API Stability - Deprecations

     /**
      * ...
      * @deprecated since 2.4M1 use {@link #transform(
      *             Block, TransformationContext)}
      */
     @Deprecated
     void transform(XDOM dom, Syntax syntax)
         throws TransformationException;




Sunday, March 31, 13
API Stability - CLIRR (1/2)
     <plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>clirr-maven-plugin</artifactId>
       <configuration>
         <ignored>
           <difference>
              <differenceType>7006</differenceType>
              <className>org/xwiki/.../MetaDataBlock</className>
              <method>org.xwiki....block.Block clone()</method>
              <to>org.xwiki.rendering.block.MetaDataBlock</to>
              <justification>XDOM#clone() doesn't clone the meta
                data</justification>
           </difference>
     ...

Sunday, March 31, 13
API Stability - CLIRR (2/2)




        Example from XWiki 5.0M1 Release notes

Sunday, March 31, 13
API Stability - Internal Package
                       Javadoc
                       <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-javadoc-plugin
                         <configuration>
                           <excludePackageNames>*.internal.*
                             </excludePackageNames>


                       CLIRR
                       <plugin>
                         <groupId>org.codehaus.mojo</groupId>
                         <artifactId>clirr-maven-plugin</artifactId>
                         <excludes>
                           <exclude>**/internal/**</exclude>
                           <exclude>**/test/**</exclude>


Sunday, March 31, 13
API Stability - Legacy Module
                            Aspect Weaving

                             <plugin>
                               <groupId>org.codehaus.mojo</groupId>
                               <artifactId>aspectj-maven-plugin</...>
                             ...
                              <configuration>
                                 <weaveDependencies>
                                   <weaveDependency>
                                     <groupId>org.xwiki.rendering</...>
                                     <artifactId>xwiki-rendering-api</...>
                             ...


                       + “Legacy” Profile

Sunday, March 31, 13
API Stability - Young APIs

     /**
       * ...
       * @since 5.0M1
       */
     @Unstable(<optional explanation>)
     public EntityReference createEntityReference(String name,...)
     {
     ...
     }

     + max duration for keeping the annotation!


Sunday, March 31, 13
API Stability - Next steps

            • Annotation or package for SPI?
            • Better define when to use the @Unstable annotation
            • Not possible to add a new method to an existing Interface
               •       Java 8 and Virtual Extension/Defender methods
                   interface TestInterface {
                     public void testMe();
                     public void newMethod() default {
                       System.out.println("Default from interface");
                     }
                   }


Sunday, March 31, 13
Quality Tip #2

                         JAR Hell




                                        27 au 29 mars 2013
Sunday, March 31, 13
The Problem



                       Class Not Found or Method Not
                        Found or not working feature




Sunday, March 31, 13
No duplicate classes @ runtime
     <plugin>
       <groupId>com.ning.maven.plugins</groupId>
       <artifactId>maven-duplicate-finder-plugin</artifactId>
       <executions>
         <execution>
           <phase>verify</phase>
           <goals>
              <goal>check</goal>
           </goals>
           <configuration>
              <failBuildInCaseOfConflict>true</...>
              <exceptions>
              ...

Sunday, March 31, 13
Surprising results...
            • Commons Beanutils bundles some classes from Commons
                   Collections, apparently to avoid drawing a dependency to it...
            •      Xalan bundles a lot of other projects (org/apache/xml/**, org/apache/
                   bcel/**, JLex/**, java_cup/**, org/apache/regexp/**). In addition, it even
                   has these jars in its source tree without any indication about their
                   versions...
            •      stax-api, geronimo-stax-api_1.0_spec and xml-apis all draw
                   javax.xml.stream.* classes
            •      xmlbeans and xml-apis draw incompatible versions of org.w3c.dom.*
                   classes
                                          14 exceptions in total!
Sunday, March 31, 13
Maven: dependency version issue
     <dependencies>
       <dependency>                                Will run logback 0.9.9
         <groupId>org.slf4j</groupId>               with slf4J-api 1.4.0
         <artifactId>slf4j-api</artifactId>          instead of 1.5.0!
         <version>1.4.0</version>
       </dependency>
       <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-classic</artifactId>
         <version>0.9.9</version>
         <!-- Depends on org.slf4j:slf4j-api:1.5.0 -->
       </dependency>
     </dependencies>

Sunday, March 31, 13
Maven: ensure correct version
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-enforcer-plugin</artifactId>
       <executions>
         <execution>
           <id>enforce-version-compatibility</id>
           <phase>verify</phase>
           <goals>
              <goal>enforce</goal>
           </goals>
           <configuration>
              <rules>
                <requireUpperBoundDeps/>
              </rules>

Sunday, March 31, 13
Quality Tip #3

                       Test Coverage




                                        27 au 29 mars 2013
Sunday, March 31, 13
The Problem



                       More bugs reported, overall quality
                        goes down and harder to debug
                                   software




Sunday, March 31, 13
Use Jacoco to fail the build
     <plugin>
       <groupId>org.jacoco</groupId>
       <artifactId>jacoco-maven-plugin</artifactId>
       <executions>
         <execution><id>jacoco-prepare</id>
           <goals><goal>prepare-agent</goal></goals>
         </execution>
         <execution><id>jacoco-check</id>
           <goals><goal>check</goal></goals>
         </execution>
       </executions>
       <configuration>
         <check>
           <instructionRatio>${xwiki.jacoco.instructionRatio}</...>
         </check>}

Sunday, March 31, 13
Strategy

            • When devs add code (and thus tests),
                   increase the TPC percentage
            •      Put the Jacoco check in “Quality” Maven
                   Profile
            •      Have a CI job to execute that profile
                   regularly
               •       About 15% overhead compared to build
                       without checks
            • “Cheat mode”: Add easier-to-write test
Sunday, March 31, 13
Quizz Time!
    Step 1: Building on my local machine gives the following:

     [INFO] --- jacoco-maven-plugin:0.6.2.201302030002:check (jacoco-check)
     [INFO] All coverage checks have been met.


    Step 2: Building on the CI machine gave:

     [INFO] --- jacoco-maven-plugin:0.6.2.201302030002:check (jacoco-check)
     [WARNING] Insufficient code coverage for INSTRUCTION: 75.52% < 75.53%


                                Non determinism! Why?
Sunday, March 31, 13
Quizz Answer
    ... because the JVM is non deterministic!
     private Map componentEntries = new ConcurrentHashMap();
     ...
     for (Map.Entry entry : componentEntries.entrySet())
     {
       if (entry.getValue().instance == component) {
         key = entry.getKey();
         oldDescriptor = entry.getValue().descriptor;
         break;
       }
     }



Sunday, March 31, 13
Quality Tip #4

                       Functional Testing Stability
                             (with Jenkins)




                                                      27 au 29 mars 2013
Sunday, March 31, 13
The Problem



                        Too many false positives leading to
                       developers not paying attention to CI
                         emails anymore... leading to failing
                                    software




Sunday, March 31, 13
False positives examples

         • The JVM has crashed
         • VNC is down (we run Selenium tests)
         • Browser crash (we run Selenium tests)
         • Git connection issue
         • Machine slowness (if XWiki cannot start under 2 minutes then it
                means the machine has some problems)
         •      Nexus is down (we deploy our artifacts to a Nexus repository)
         •      Connection issue (Read time out)

Sunday, March 31, 13
Step 1: Groovy PostBuild Plugin (1/2)
     def messages = [
       [".*A fatal error has been detected by the Java Runtime Environment.*",
         "JVM Crash", "A JVM crash happened!"],
       [".*Error: cannot open display: :1.0.*",
         "VNC not running", "VNC connection issue!"],
       ...
     ]
     def shouldSendEmail = true
     messages.each { message ->
       if (manager.logContains(message.get(0))) {
          manager.addWarningBadge(message.get(1))
          manager.createSummary("warning.gif").appendText(...)
          manager.buildUnstable()
          shouldSendEmail = false
       }
     }

Sunday, March 31, 13
Step 1: Groovy PostBuild Plugin (2/2)


     ... continued from previous slide...

     if (!shouldSendEmail) {
       def pa = new ParametersAction([
          new BooleanParameterValue("noEmail", true)
       ])
       manager.build.addAction(pa)
     }




Sunday, March 31, 13
Step 2: Mail Ext Plugin

    Pre-send Script
     import hudson.model.*

     build.actions.each { action ->
       if (action instanceof ParametersAction) {
         if (action.getParameter("noEmail")) {
           cancel = true
         }
       }
     }




Sunday, March 31, 13
Results




             + use the Scriptler plugin to automate configuration for all jobs
Sunday, March 31, 13
Quality Tip #5

                       Bug Fixing Day




                                        27 au 29 mars 2013
Sunday, March 31, 13
The Problem

                        Bugs increasing, even simple to fix
                       ones, devs focusing too much on new
                        features (i.e. scope creep) vs fixing   Bugs created vs closed
                                     what exists




Sunday, March 31, 13
Bug Fixing Day

         • Every Thursday
         • Goal is to close the max number of bugs
         • Triaging: Can be closed with Won’t fix, Duplicate,
                Cannot Reproduce, etc
         •      Close low hanging fruits in priority
         •      Started with last 365 days then with last 547 days
                and currently with last 730 days (we need to catch
                up with 40 bugs!)


Sunday, March 31, 13
Results




Sunday, March 31, 13
Conclusion




                                    27 au 29 mars 2013
Sunday, March 31, 13
Parting words

            • Slowly add new quality check over time
            • Everyone must be on board
            • Favor Active Quality (i.e. make the build fail) over Passive checks
            • Be ready to adapt/remove checks if found not useful enough
            • Quality brings some risks:
               •       Potentially less committers for your project (especially open source)
               •       Project seen as “less fun”




Sunday, March 31, 13
Be proud of your Quality!

                          “I have offended God and
                       mankind because my work didn't
                       reach the quality it should have.”

                                       Leonardo da Vinci, on his death bed




Sunday, March 31, 13

More Related Content

PDF
Implementing quality in Java projects
PDF
NetBeans Support for EcmaScript 6
PDF
JavaScript + Jenkins = Winning!
PDF
Arquillian in a nutshell
PPTX
Test-Driven JavaScript Development (JavaZone 2010)
PDF
Gradle Introduction
KEY
うさぎ組 in G* WorkShop -うさみみの日常-
PDF
Scala and Play with Gradle
Implementing quality in Java projects
NetBeans Support for EcmaScript 6
JavaScript + Jenkins = Winning!
Arquillian in a nutshell
Test-Driven JavaScript Development (JavaZone 2010)
Gradle Introduction
うさぎ組 in G* WorkShop -うさみみの日常-
Scala and Play with Gradle

What's hot (20)

PDF
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
PDF
Testcontainers - Geekout EE 2017 presentation
PPTX
The world of gradle - an introduction for developers
PDF
Ant, Maven and Jenkins
PDF
An Introduction to Gradle for Java Developers
PDF
Deploying JHipster Microservices
PDF
Gradle talk, Javarsovia 2010
PDF
OpenJDK-Zulu talk at JEEConf'14
PDF
Hands on the Gradle
PPTX
Getting started with sbt
PDF
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
PDF
Efficient JavaScript Unit Testing, May 2012
PDF
Managing dependencies with gradle
PDF
Jenkinsプラグインの作り方
PDF
Gradle como alternativa a maven
PDF
Integration tests: use the containers, Luke!
PPTX
First adoption hackathon at BGJUG
PDF
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
PPT
Java build tool_comparison
PDF
Take Control of your Integration Testing with TestContainers
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Testcontainers - Geekout EE 2017 presentation
The world of gradle - an introduction for developers
Ant, Maven and Jenkins
An Introduction to Gradle for Java Developers
Deploying JHipster Microservices
Gradle talk, Javarsovia 2010
OpenJDK-Zulu talk at JEEConf'14
Hands on the Gradle
Getting started with sbt
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Efficient JavaScript Unit Testing, May 2012
Managing dependencies with gradle
Jenkinsプラグインの作り方
Gradle como alternativa a maven
Integration tests: use the containers, Luke!
First adoption hackathon at BGJUG
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
Java build tool_comparison
Take Control of your Integration Testing with TestContainers
Ad

Viewers also liked (17)

KEY
Adding Integers
PDF
Grenville Castings New Brochure
PPT
368b.6819.file
PPT
Empathize and define
PPTX
Evaluation Question 5
PPT
Group 51 presentation
DOCX
nhận làm video quảng cáo 3d
PDF
Epic research malaysia daily klse report for 21st march 2016
PDF
Cognitive neuro fuzzy expert system for hypotension control
PDF
financial statement 2004
PPTX
book review by Vladimir Pyavka
PDF
GGilbert_Three_Images_of_Konstantin_Pats
PPT
Escuela inteligente
PDF
IMARK NOW Summer LEDs and the Future
PPTX
Costume ideas
PPTX
Customer Success Story: Slimband
PDF
832 русский язык. 11кл. мурина л.а. и др.-минск, 2010 -280с
Adding Integers
Grenville Castings New Brochure
368b.6819.file
Empathize and define
Evaluation Question 5
Group 51 presentation
nhận làm video quảng cáo 3d
Epic research malaysia daily klse report for 21st march 2016
Cognitive neuro fuzzy expert system for hypotension control
financial statement 2004
book review by Vladimir Pyavka
GGilbert_Three_Images_of_Konstantin_Pats
Escuela inteligente
IMARK NOW Summer LEDs and the Future
Costume ideas
Customer Success Story: Slimband
832 русский язык. 11кл. мурина л.а. и др.-минск, 2010 -280с
Ad

Similar to Implementing Quality on Java projects (20)

PDF
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
PDF
Implementing Quality on a Java Project
KEY
4 maven junit
PDF
In the Brain of Hans Dockter: Gradle
PDF
Jdc 2010 - Maven, Intelligent Projects
PDF
Building XWiki
PDF
Apache Maven - eXo TN presentation
PDF
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
PDF
Lorraine JUG (1st June, 2010) - Maven
PPTX
Apache Maven
PDF
Gradle - time for a new build
PDF
Jsf, facelets, spring, hibernate, maven2
PDF
JSF, Facelets, Spring-JSF & Maven
PDF
Gradle
PDF
Intelligent Projects with Maven - DevFest Istanbul
PDF
Make Your Builds More Groovy
PDF
make builds groovy
PDF
What's new with tooling for Spring, Grails, and the Cloud
PDF
Maven 3 Overview
PDF
Lausanne Jug (08th April, 2010) - Maven
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Implementing Quality on a Java Project
4 maven junit
In the Brain of Hans Dockter: Gradle
Jdc 2010 - Maven, Intelligent Projects
Building XWiki
Apache Maven - eXo TN presentation
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
Lorraine JUG (1st June, 2010) - Maven
Apache Maven
Gradle - time for a new build
Jsf, facelets, spring, hibernate, maven2
JSF, Facelets, Spring-JSF & Maven
Gradle
Intelligent Projects with Maven - DevFest Istanbul
Make Your Builds More Groovy
make builds groovy
What's new with tooling for Spring, Grails, and the Cloud
Maven 3 Overview
Lausanne Jug (08th April, 2010) - Maven

More from Vincent Massol (20)

PDF
XWiki Testing with TestContainers
PDF
XWiki: The best wiki for developers
PDF
Advanced Java Testing @ POSS 2019
PDF
New types of tests for Java projects
PDF
Configuration Testing with Docker & TestContainers
PDF
New types of tests for Java projects
PDF
What's new in XWiki 9.x and 10.x
PDF
QDashboard 1.2
PDF
Advanced Java Testing
PDF
Creating your own project's Quality Dashboard
PDF
XWiki: wiki collaboration as an alternative to Confluence and Sharepoint
PDF
Creating your own project's Quality Dashboard
PDF
XWiki: The web's Swiss Army Knife
PDF
Leading a Community-Driven Open Source Project
PDF
Developing XWiki
PDF
XWiki Status - July 2015
PDF
XWiki SAS development practices
PDF
XWiki SAS: An open source company
PDF
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014
PDF
XWiki Rendering @ FOSDEM 2014
XWiki Testing with TestContainers
XWiki: The best wiki for developers
Advanced Java Testing @ POSS 2019
New types of tests for Java projects
Configuration Testing with Docker & TestContainers
New types of tests for Java projects
What's new in XWiki 9.x and 10.x
QDashboard 1.2
Advanced Java Testing
Creating your own project's Quality Dashboard
XWiki: wiki collaboration as an alternative to Confluence and Sharepoint
Creating your own project's Quality Dashboard
XWiki: The web's Swiss Army Knife
Leading a Community-Driven Open Source Project
Developing XWiki
XWiki Status - July 2015
XWiki SAS development practices
XWiki SAS: An open source company
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014
XWiki Rendering @ FOSDEM 2014

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Spectroscopy.pptx food analysis technology
Teaching material agriculture food technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Review of recent advances in non-invasive hemoglobin estimation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Spectroscopy.pptx food analysis technology

Implementing Quality on Java projects

  • 1. Implementing Quality on Java projects Vincent Massol Committer XWiki XWiki SAS @vmassol 27 au 29 mars 2013 Sunday, March 31, 13
  • 2. Vincent Massol • Speaker Bio • CTO XWiki SAS • Your Projects • XWiki (community-driven open source project) • Past: Maven, Apache Cargo, Apache Cactus, Pattern Testing • Other Credentials: • LesCastCodeurs podcast • Creator of OSSGTP open source group in Paris • 3 books: JUnit in Action, Maven: A Developer’s Notebook, BBWM Sunday, March 31, 13
  • 4. The XWiki project in summary • 9 years old • 28 active committers • 7 committers do 80% of work • 700K NCLOC • 11 commits/ day • 16 mails/day Sunday, March 31, 13
  • 5. Examples of Quality actions • Coding rules (Checkstyle, ...) • Ensure API stability • Test coverage • Code reviews • Track bugs • License header checks • Don’t use Commons Lang 2.x • Release with Java 6 • Use SLF4J and don’t draw Log4J/ • Ensure javadoc exist JCL in dependencies • Prevent JAR hell • Automated build • Release often (every 2 weeks) • Automated unit tests • Collaborative design • Stable automated • Test on supported functional tests environments (DB & Browsers) Sunday, March 31, 13
  • 6. Quality Tip #1 API Stability 27 au 29 mars 2013 Sunday, March 31, 13
  • 7. The Problem Class Not Found or Method Not Found Sunday, March 31, 13
  • 8. API Stability - Deprecations /** * ... * @deprecated since 2.4M1 use {@link #transform( * Block, TransformationContext)} */ @Deprecated void transform(XDOM dom, Syntax syntax) throws TransformationException; Sunday, March 31, 13
  • 9. API Stability - CLIRR (1/2) <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>clirr-maven-plugin</artifactId> <configuration> <ignored> <difference> <differenceType>7006</differenceType> <className>org/xwiki/.../MetaDataBlock</className> <method>org.xwiki....block.Block clone()</method> <to>org.xwiki.rendering.block.MetaDataBlock</to> <justification>XDOM#clone() doesn't clone the meta data</justification> </difference> ... Sunday, March 31, 13
  • 10. API Stability - CLIRR (2/2) Example from XWiki 5.0M1 Release notes Sunday, March 31, 13
  • 11. API Stability - Internal Package Javadoc <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin <configuration> <excludePackageNames>*.internal.* </excludePackageNames> CLIRR <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>clirr-maven-plugin</artifactId> <excludes> <exclude>**/internal/**</exclude> <exclude>**/test/**</exclude> Sunday, March 31, 13
  • 12. API Stability - Legacy Module Aspect Weaving <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</...> ... <configuration> <weaveDependencies> <weaveDependency> <groupId>org.xwiki.rendering</...> <artifactId>xwiki-rendering-api</...> ... + “Legacy” Profile Sunday, March 31, 13
  • 13. API Stability - Young APIs /** * ... * @since 5.0M1 */ @Unstable(<optional explanation>) public EntityReference createEntityReference(String name,...) { ... } + max duration for keeping the annotation! Sunday, March 31, 13
  • 14. API Stability - Next steps • Annotation or package for SPI? • Better define when to use the @Unstable annotation • Not possible to add a new method to an existing Interface • Java 8 and Virtual Extension/Defender methods interface TestInterface {   public void testMe();   public void newMethod() default {     System.out.println("Default from interface");   } } Sunday, March 31, 13
  • 15. Quality Tip #2 JAR Hell 27 au 29 mars 2013 Sunday, March 31, 13
  • 16. The Problem Class Not Found or Method Not Found or not working feature Sunday, March 31, 13
  • 17. No duplicate classes @ runtime <plugin> <groupId>com.ning.maven.plugins</groupId> <artifactId>maven-duplicate-finder-plugin</artifactId> <executions> <execution> <phase>verify</phase> <goals> <goal>check</goal> </goals> <configuration> <failBuildInCaseOfConflict>true</...> <exceptions> ... Sunday, March 31, 13
  • 18. Surprising results... • Commons Beanutils bundles some classes from Commons Collections, apparently to avoid drawing a dependency to it... • Xalan bundles a lot of other projects (org/apache/xml/**, org/apache/ bcel/**, JLex/**, java_cup/**, org/apache/regexp/**). In addition, it even has these jars in its source tree without any indication about their versions... • stax-api, geronimo-stax-api_1.0_spec and xml-apis all draw javax.xml.stream.* classes • xmlbeans and xml-apis draw incompatible versions of org.w3c.dom.* classes 14 exceptions in total! Sunday, March 31, 13
  • 19. Maven: dependency version issue <dependencies> <dependency> Will run logback 0.9.9 <groupId>org.slf4j</groupId> with slf4J-api 1.4.0 <artifactId>slf4j-api</artifactId> instead of 1.5.0! <version>1.4.0</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.9</version> <!-- Depends on org.slf4j:slf4j-api:1.5.0 --> </dependency> </dependencies> Sunday, March 31, 13
  • 20. Maven: ensure correct version <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-version-compatibility</id> <phase>verify</phase> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireUpperBoundDeps/> </rules> Sunday, March 31, 13
  • 21. Quality Tip #3 Test Coverage 27 au 29 mars 2013 Sunday, March 31, 13
  • 22. The Problem More bugs reported, overall quality goes down and harder to debug software Sunday, March 31, 13
  • 23. Use Jacoco to fail the build <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution><id>jacoco-prepare</id> <goals><goal>prepare-agent</goal></goals> </execution> <execution><id>jacoco-check</id> <goals><goal>check</goal></goals> </execution> </executions> <configuration> <check> <instructionRatio>${xwiki.jacoco.instructionRatio}</...> </check>} Sunday, March 31, 13
  • 24. Strategy • When devs add code (and thus tests), increase the TPC percentage • Put the Jacoco check in “Quality” Maven Profile • Have a CI job to execute that profile regularly • About 15% overhead compared to build without checks • “Cheat mode”: Add easier-to-write test Sunday, March 31, 13
  • 25. Quizz Time! Step 1: Building on my local machine gives the following: [INFO] --- jacoco-maven-plugin:0.6.2.201302030002:check (jacoco-check) [INFO] All coverage checks have been met. Step 2: Building on the CI machine gave: [INFO] --- jacoco-maven-plugin:0.6.2.201302030002:check (jacoco-check) [WARNING] Insufficient code coverage for INSTRUCTION: 75.52% < 75.53% Non determinism! Why? Sunday, March 31, 13
  • 26. Quizz Answer ... because the JVM is non deterministic! private Map componentEntries = new ConcurrentHashMap(); ... for (Map.Entry entry : componentEntries.entrySet()) { if (entry.getValue().instance == component) {   key = entry.getKey();     oldDescriptor = entry.getValue().descriptor;     break;   } } Sunday, March 31, 13
  • 27. Quality Tip #4 Functional Testing Stability (with Jenkins) 27 au 29 mars 2013 Sunday, March 31, 13
  • 28. The Problem Too many false positives leading to developers not paying attention to CI emails anymore... leading to failing software Sunday, March 31, 13
  • 29. False positives examples • The JVM has crashed • VNC is down (we run Selenium tests) • Browser crash (we run Selenium tests) • Git connection issue • Machine slowness (if XWiki cannot start under 2 minutes then it means the machine has some problems) • Nexus is down (we deploy our artifacts to a Nexus repository) • Connection issue (Read time out) Sunday, March 31, 13
  • 30. Step 1: Groovy PostBuild Plugin (1/2) def messages = [ [".*A fatal error has been detected by the Java Runtime Environment.*", "JVM Crash", "A JVM crash happened!"], [".*Error: cannot open display: :1.0.*", "VNC not running", "VNC connection issue!"], ... ] def shouldSendEmail = true messages.each { message -> if (manager.logContains(message.get(0))) { manager.addWarningBadge(message.get(1)) manager.createSummary("warning.gif").appendText(...) manager.buildUnstable() shouldSendEmail = false } } Sunday, March 31, 13
  • 31. Step 1: Groovy PostBuild Plugin (2/2) ... continued from previous slide... if (!shouldSendEmail) { def pa = new ParametersAction([ new BooleanParameterValue("noEmail", true) ]) manager.build.addAction(pa) } Sunday, March 31, 13
  • 32. Step 2: Mail Ext Plugin Pre-send Script import hudson.model.* build.actions.each { action -> if (action instanceof ParametersAction) { if (action.getParameter("noEmail")) { cancel = true } } } Sunday, March 31, 13
  • 33. Results + use the Scriptler plugin to automate configuration for all jobs Sunday, March 31, 13
  • 34. Quality Tip #5 Bug Fixing Day 27 au 29 mars 2013 Sunday, March 31, 13
  • 35. The Problem Bugs increasing, even simple to fix ones, devs focusing too much on new features (i.e. scope creep) vs fixing Bugs created vs closed what exists Sunday, March 31, 13
  • 36. Bug Fixing Day • Every Thursday • Goal is to close the max number of bugs • Triaging: Can be closed with Won’t fix, Duplicate, Cannot Reproduce, etc • Close low hanging fruits in priority • Started with last 365 days then with last 547 days and currently with last 730 days (we need to catch up with 40 bugs!) Sunday, March 31, 13
  • 38. Conclusion 27 au 29 mars 2013 Sunday, March 31, 13
  • 39. Parting words • Slowly add new quality check over time • Everyone must be on board • Favor Active Quality (i.e. make the build fail) over Passive checks • Be ready to adapt/remove checks if found not useful enough • Quality brings some risks: • Potentially less committers for your project (especially open source) • Project seen as “less fun” Sunday, March 31, 13
  • 40. Be proud of your Quality! “I have offended God and mankind because my work didn't reach the quality it should have.” Leonardo da Vinci, on his death bed Sunday, March 31, 13