Contributing to Gr8 Technologies

Dan Hyun

Who?

Dan Hyun

Software Engineer Mindspark

Groovy usage

~1 year personally/professionally

  • Groovy

  • Gradle

  • Spock

What?

How to…​

  • Contribute to Groovy

  • Contribute to Grails

  • Contribute to Gr8 Technologies

My Groovy Experience

  1. Wanted to use Gradle

  2. I had no idea where to start

  3. Decided I needed to learn Groovy

Groovy whirlwind

Started with Grails In Action 2nd Ed.
Led me to Peter LedbrookGroovyPodcast → GR8Conf

Continued with Groovy In Action 2nd Ed.
and watching talks from GR8Conf youtube Channel

Follow Guillaume’s Groovy Weekly Update

Participation on twitter #groovylang

Groovy Exposure

From

no idea

Groovy Exposure

To

i know some of these words

How to find ways to contribute?

USAGE

utilization → reading docs → executing sample code → encountering bugs (Groovy Puzzlers??)

EXPOSURE

Usage comes from exposure

COMMUNITY

Exposure comes from community

How to find ways to contribute?

Participate at any of these levels
you eventually find your way to source code

Current State of Affairs

Groovy/Grails development no longer
financially supported by Pivotal

Most recent Groovy/Grails Wins

Groovy 2.4 (Groovy on Android!!!!)
Grails 3.0 (Complete rewrite on Spring Boot)

The Groovy Community

  • Friendly

  • Positive

  • Lots of Gr8 OSS projects

  • and HORSEGROOVY

How I envision the Groovy Community

F.U.B.U == For Us By Us

fubu

Levels of Contribution

  • Community

  • Usage

  • Source Code

A Gr8 Community Contribution

Le Prince de Bel Aire

Another Gr8 Community Contribution

ftfy

Contributing to Groovy

Contributing to Groovy

groovy contribute

Documenting

So don’t hesitate to help us improve it, fix typos, broken language, clarify complicated sections, add new material, etc.

— Groovy Contribution Guide

Documentation

The "Hello, World!" of contributions

Discover typos by usage

Groovy team merges corrections!

typos count

The possibilities

green streak

Updated CV

Expert Groovy OSS Documentation Contributor

— Your Name Here

Become the next Groovy Knight

groovy knight

Live Documentation Contribution

warning

Preflight Checklist

  • Learn and download git

  • Github Account

  • git clone git://github.com/apache/incubator-groovy.git

  • Push finished code to your own fork

  • Create PR with relevant info

Finding an issue

While reading some Javadoc…​

DefaultGroovyMethods.java
   /**
     * Iterates through an List,
     * passing each item and the item's index (a counter starting at
     * zero) to the given closure.
     *
     * @param self    an List
     * @param closure a Closure to operate on each item
     * @return the self List
     * @since 2.4.0
     */
     public static <T> List<T> eachWithIndex(...) {...}

The Typo

an List

Bingo!

Time to contribute!

Scope out the work

$ grep -ir "\([^a-zA-Z]\)an \(list\)" .
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * @param self       an List
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * @param self       an List
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * Iterates through an List,
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * @param self    an List
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * Iterates through an List, passing each item to the given closure.
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * @param self an List
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * @param self an List
./src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:     * @param self   an List
./src/main/org/codehaus/groovy/runtime/InvokerHelper.java:            // value is an list.
./src/main/org/codehaus/groovy/runtime/InvokerHelper.java:            // value is an list.
./subprojects/groovy-jmx/src/main/groovy/groovy/jmx/builder/JmxListenerFactory.groovy: * This factory class is used to create an listener() node for JmxBuilder.  Listener nodes are used

Doing the work

$ grep -ir "\([^a-zA-Z]\)an \(list\)" . | cut -d":" -f1 \
| sort -u | xargs sed -i 's/\([^a-zA-Z]\)an \(list\)/\1a \2/ig'

Verification

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
        modified:   src/main/org/codehaus/groovy/runtime/InvokerHelper.java
        modified:   subprojects/groovy-jmx/src/main/groovy/groovy/jmx/builder/JmxListenerFactory.groovy

$ git diff -b

Respect the project’s Protocol

Don’t want to waste anyone’s time

  • Make sure it compiles locally

  • Run tests

  • Etc

Submit PR

Provide some relevant information
about the work you’ve done.

Reference ticket numbers, etc…​

Is it merged yet?

wait

Want more?

Groovy and Asciidoctor

src/spec/doc/design-pattern-singleton.adoc
 We can use this singleton class in some script code as follows:

 [source,groovy]
 ----
 include::{projectdir}/src/spec/test/DesignPatternsTest.groovy[tags=singleton_vote_collector_usage,indent=0]
 ----

Corresponding Code

src/spec/test/DesignPatternsTest.groovy
  // tag::singleton_vote_collector_usage[]
  def collector = VoteCollector.instance
  collector.display()
  collector.votes++
  collector = null
  Thread.start{
      def collector2 = VoteCollector.instance
      collector2.display()
      collector2.votes++
      collector2 = null
  }.join()
  def collector3 = VoteCollector.instance
  collector3.display()
  // end::singleton_vote_collector_usage[]

Result

asciidoctor output

Contributing to Grails

Grails is also a Good OSS Project.

Grails’s recommendations

grails contribute

Grails also accepts typos

grails typos too

Finding an Issue

grails doc

Another contribution opportunity!

feels good

Some background

to indent or not to indent

To Indent or not to Indent?

Regardless of preference
indentation should be consistent

Inconsistency

Confusing for the uninitiated

What is Spock or Geb?

Do I need to indent for this to work?

Why is it different?

Unit Test

unit test

Confusion

New users may believe:

Unit tests == no indents

Functional tests == indentation

LIVE PR

Now we wait again

clock

Want to contribute more?

Stack Overflow

Participate on StackOverflow

Code

Subscribe to the mailing-list
and indicate that you would like to do so.

GR8 OSS

There are a lot of
projects that use Groovy.

Feel free to explore and make
similar contributions.

Contribute!

Say hello with #groovylang

Contribute some typo corrections

Get involved on Stack Overflow

Questions?