Java build tool_comparison
-
Upload
manav-prasad -
Category
Technology
-
view
204 -
download
0
Transcript of Java build tool_comparison
![Page 1: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/1.jpg)
Java Build Tool Comparison
![Page 2: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/2.jpg)
Java Build Tool Comparison
• Desired Features• The Contenders
• Ant + Ivy• Maven• Gradle• Buildr• Others
• Results Matrix• Subjective Evaluation• Which Would You Choose?
![Page 3: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/3.jpg)
Desired Features
• Dependency management• Versioning• Compile Java code, build jars• Execute tests and report results, fail build on failed tests• Run quality-check tools (PMD, Findbugs, Checkstyles)• File generation (XmlBeans, Xsl, Velocity, AspectJ)• Property expansion / token substitution• Build vs. deploy vs. release• Full control when needed• Cross-platform• IDE Support• Documentation / Support
![Page 4: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/4.jpg)
Ant + Ivy
Ant is ubiquitous Java-based build toolUses XML “script” files
Ivy is a dependency managerArtifact repositoryDependency resolution, including transitive
(Project A -> Hibernate -> Commons-Collections)
Sync with external repositories
![Page 5: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/5.jpg)
Ant + Ivy Module dependencies are declared in ivy.xml
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<info organisation=“org.hjug" module=“myModule"/> <dependencies> <dependency org="org.apache" name="ant" rev="1.7.0"/> <dependency org="org.apache" name="axis" rev="1.2rc3"/> <dependency org="org.junit" name="junit" rev="4.4"/> </dependencies></ivy-module>
![Page 6: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/6.jpg)
Ant + Ivy Add this to your Ant buildfile (build.xml)
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="pdk" default="default" basedir="."> … <!-- Ivy Taskdefs --> <path id="ivy.lib.path"> <fileset dir="C:/java-tools/apache-ivy-2.0.0" includes="*.jar"/> </path> <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant"
classpathref="ivy.lib.path"/> <!-- Reference Ivy settings --> <ivy:settings file="${basedir}/../ivysettings.xml"/> <target name="ivy.resolve" description="--> retrieve dependencies with ivy"> <ivy:retrieve pattern=“${lib.dir}/[conf]/[artifact].[ext]”/> </target> <target name="ivy.publish" description="--> publish artifacts to local repository"> <ivy:publish resolver=“local” pubrevision=“${version}”>
<artifacts pattern=“dist/[artifact].[ext]”/></ivy:publish>
</target>
![Page 7: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/7.jpg)
Ant + Ivy
Build steps defined and executed with Ant Dependencies managed with Ivy Ant targets to install, retrieve artifacts
from Ivy repository
![Page 8: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/8.jpg)
Ant + Ivy
Image copied from http://ant.apache.org/ivy/history/2.0.0/principle.html
![Page 9: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/9.jpg)
Maven
Project is defined by POM (Project Object Model) Projects can contain sub-projects (modules) Based on recommended project structure (e.g.
src/main/java, src/main/resources, src/test/java, …) Artifact-focused (i.e. What files does this build
produce?) Heavy emphasis on default configuration
![Page 10: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/10.jpg)
Maven Build Lifecycle is defined as Phases, which
execute sequentially1. Validate2. Compile3. Test4. Package5. Integration-test6. Verify7. Install8. Deploy
![Page 11: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/11.jpg)
Maven
Each Phase can be made up of zero or more Goals (tasks) Project-specific configuration involves binding
specific goals to specific phases (beyond the default settings)
Extensible plugin system (called Mojos) Java-based or Ant-based Comprehensive set of third-party plugins available
![Page 12: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/12.jpg)
Gradle
Built on top of Ant + Ivy Build DSL written in Groovy Uses Groovy AntBuilder
ant.compile, ant.jar Plugins define common tasks to build
different types of projects java, groovy, war, …
![Page 13: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/13.jpg)
Gradle
Assumes Maven conventions for file locations (drop-in replacement for Maven)Can be altered with the convention object
Can use existing Maven or Ivy repositories
![Page 14: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/14.jpg)
Buildr
Built on RubyRake is similar to Ant (Ruby Make)RubyGems is similar to rpm (package
manager, handles dependencies)Build script written in Ruby (internal DSL)
![Page 15: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/15.jpg)
Buildr Pre-defined tasks
clean compile build upload install javadoc package test uninstall
![Page 16: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/16.jpg)
Buildr
Assumes Maven conventions for file locations (drop-in replacement for Maven)Can be altered
Can use existing Maven repositories
![Page 17: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/17.jpg)
Others
Gant Rake EasyAnt Custom ?
![Page 18: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/18.jpg)
Results MatrixDesired Feature Ant + Ivy Maven Gradle Buildr
Dependency management
Versioning manually
Compile Java code, build jars
Execute tests, report results, fail build on failed tests
Doesn’t include html reports
Doesn’t include html reports
Run quality check tools (PMD, FindBugs, JavaDoc)
3rd party task libraries
3rd party plugins
Manually Manually
File generation (XmlBeans, XSL, Velocity, AspectJ)
3rd party task libraries
3rd party plugins
Manually Manually
Out of the box
Not supported
![Page 19: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/19.jpg)
Results Matrix cont’dDesired Feature Ant + Ivy Maven Gradle Buildr
Property expansion / token substitution
Build vs. deploy vs. release Manually defined
Full control when needed Custom XML “scripts”
Write custom plugin or embedded Ant script
Groovy code directly in build file
Ruby code directly in build file
Cross-platformRuns on JVM Runs on JVM Runs on JVM
Runs on Ruby, may need to compile from source
IDE SupportEclipse only
Documentation / Support Excellent Growing but still inconsistent
Decent project documentation, few articles
Good project documentation, few articles
Out of the box
Not supported
![Page 20: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/20.jpg)
Subjective Evaluation Ant, Ivy, Maven have been around the longest Restrictive vs. Open philosophy Smart defaults Dependency Management is a Good Thing™ Ant has by far the best documentation and
examples available online Gradle is the least mature (but very promising) Buildr is very cool but has potential platform
issues (Ruby vs. JRuby, 64-bit)
![Page 21: Java build tool_comparison](https://reader035.fdocuments.net/reader035/viewer/2022062902/58efeb811a28abe02b8b461f/html5/thumbnails/21.jpg)
Which Would You Choose?