pimp my build - oracle · bitstrips skitch atlassian sjug terence pete questions? pimp my build...

37
PIMP MY BUILD Matt Quail & Conor MacNeill TS-5596

Upload: others

Post on 20-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

PIMP MY BUILD

Matt Quail &Conor MacNeill TS-5596

Page 2: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 2

Page 3: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 3

Your Build Sucks <!-- any parameters passed by ant to JVM to be used by Junit tests (e.g. path to Perforce executables) --> <property name="junit.jvmargs" value=""/> <property name="p4d.exe" value=""/> <property name="p4.exe" value=""/>

<fileset id="jetty.build.fileset" dir="${jetty.dir}"> <include name="${maven.dependencies.dir}/servlet-api-2.5-*.jar" /> <include name="${maven.dependencies.dir}/jetty-6.1.*.jar" /> <include name="${maven.dependencies.dir}/jetty-util-6.1.*.jar" /> <include name="${maven.dependencies.dir}/jsp-2.1*.jar" /> <include name="${maven.dependencies.dir}/jsp-api-2.1*.jar" /> <include name="${maven.dependencies.dir}/jetty-ajp-6.1*.jar" /> </fileset>

<fileset id="shaj.fileset" dir="${shaj.dir}" includes="*.jar"/>

<fileset id="svnkit.fileset" dir="${maven.dependencies.dir}"> <include name="**/svnkit*.jar"/> <include name="**/ganymed*.jar"/> <include name="**/jna*.jar"/> <include name="**/sqlitejdbc*.jar"/> </fileset>

Page 4: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 4

In this talk you might learn

Some ways to improve your Ant buildHow to make your Maven build work (maybe)Maintainability strategiesFun things to try

Page 5: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 5

Ground Rules

We’re Ant Centric Applies to Maven builds as well

If you use Make, leave now ;)

We are not trying to convert you.

Page 6: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 6

#1: Use Imports

emo

Page 7: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 7

Import Benefits

se Imports to modularize your build

ove all the targets that do not change across projects into a common module

mport the module into your build and override as appropriate

eparate what your build needs to do from the details of how it’s done

Page 8: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 8

#2: Use Macros and Presets

ive off common groups of operations into macros

ake your build simpler, easier to read

es, <xml> does suck for readability and usability• Don’t tell us - Terence Parr already did• Really

Page 9: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 9

Macro Example - .NET build

macrodef name="devenv">

<attribute name="solution"/>

<attribute name="config"/>

<sequential>

<exec taskname="devenv” executable=“devenv.com”vmlauncher="false">

<arg value="@{solution}"/>

<arg value="/build"/>

<arg value="@{config}"/>

</exec>

</sequential>

</macrodef>

<devenv solution="CloverAll.sln" config="Debug"/>

Page 10: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 10

#3: Don’t Build Stuff you don’t Need

se the <uptodate> task

t is complex• Invest the time to get it right in the build• Keep you and your team productive• The build will remember how to do it• Put it in a macro and make its use simple

se <outofdate> from ant-contrib• Even better

Page 11: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 11

#4: Spice Up Your Build

emo

Page 12: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 12

Build Fun

dd a splash image• Associate it with a sprint, a scrum, an iteration, a

blast, whatever you call it.• It’s a bit of fun• Add some stupid cat image

dd some sound• You can watch youtube while your build does its

thing• At least this way you come back to your build when

it’s done• Add the blame train toot

Page 13: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 13

Clover Splash Timeline

Page 14: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 14

Page 15: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 15

Page 16: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 16

Page 17: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 17

Censored

Page 18: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 18

Censored

Page 19: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 19

Page 20: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 20

Page 21: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 21

Page 22: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 22

Censored

Page 23: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 23

Maven Tips

Page 24: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 24

Maven Growl Notifications

Mac OSX growlnotify for your maven builds

#! /bin/shmvn $* | awk '{ print; if($0 ~ ".*Downloading.*") system("/usr/local/bin/growlnotify -n mavenError -t Maven Downloading -m\""$0 "\"") if($0 ~ ".*ERROR.*") system("/usr/local/bin/growlnotify -n mavenError -t Maven Error -m\""$0 "\"") } END {system("/usr/local/bin/growlnotify -n mavenComplete -t Maven -m \"Build Complete\"")}'

Page 25: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 25

#5: Don't Be Afraid to write Tasks

es, tasks are code, but we’re coders.

on’t separate your team into builders and coders• Everyone should know how the build works• The build should not be precious or off-limits

•But …

Page 26: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 26

Page 27: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 27

#6: Use Scripts

Ant let’s you define tasks with scripts <scriptdef name="versiondays" language="javascript"> <attribute name="propname"/> <![CDATA[ now = new java.util.Date(); millis = now.getTime(); days = millis / 86400000 - 10957; project.setProperty(attributes.get("propname"), days.toFixed(0).toString()); ]]> </scriptdef>

<versiondays propname="version.day"/>

Page 28: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 28

#7: Use Conditional Tasks

Yes, you should try to be declarative, but<if> <os family="mac"/> <then> <property name="gwt.vmargs" value="-XstartOnFirstThread"/> </then> <else> <property name="gwt.vmargs" value=""/> </else> </if>

Use ant-contrib tasks

Page 29: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 29

#8: Don't do One-Off Analysis

Your build is a way of recording how to do a set of complex operations.

Heaps of Analysis tool out there - USE THEM◦ FindBugs, CheckStyle, PMD, Clover, etc◦ Put them in your build◦ ant checkstyle is easy to remember◦ mvn lifecycly goaly:thingy

Ok, I can’t remember it but it’s sorta easy ;)

Page 30: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 30

#9: Document Your Build

dd descriptions

dd comments

se the –target_name convention for private targets• No, it’s not perfect• Yes, it does work• It’s called an idiom

Page 31: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 31

More Doing Things

emember your build is where you document the tasks in your projects• Run tests• Run the build• Create the license file• Generate Coverage reports• Yes, that is a shameless plug

• Attach debuggers, run profilers

ive newbies a leg up• You can add a few newbie surprises too

Page 32: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 32

Continuous integration

ou are doing continuous integration right?!• If you are not please tell me why• Actually just tell me the name of your product

• Controlled Build Environment• Automated Testing and Reporting• Its easy because it is already in your build file

Page 33: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 33

Testing

o I need to say anything here?

Page 34: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 34

Repetitive Tasks

utomate them

on’t ever type a long series of commands twice

ut them in the build to remember them

Page 35: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 35

#10 Maven Best Practice Tips

Use a remote repository proxy• Archiva

Create a local repository for private artifacts• Your own artifacts• Missing third party artifacts

Local repository for public artifacts• Artifacts you are making available

You need to manage your build infrastructure

Page 36: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

2008 JavaOneSM Conference | java.sun.com/javaone | 36

Thanks

BitstripsSkitchAtlassianSJUGTerencePete

Questions?

Page 37: PIMP MY BUILD - Oracle · Bitstrips Skitch Atlassian SJUG Terence Pete Questions? Pimp my Build Conor MacNeill & Matt Quail TS-5596 Speaker’s logo here (optional) Title: PRESENTATION

Pimp my BuildConor MacNeill & Matt Quail

TS-5596

Speaker’s logo here (optional)