Software Engineering - Development Infrastructure 2 Kristjan Talvar kristjan.talvar@nortal.com Nortal
Topics Different build tools Gradle demo Github as collaboration tool
About me Java dev for almost 2 years EMPIS - Unemployed Information Management System Eclipse, Ant, Ivy, Spring, Aranea, Tomcat Mercural, Jira, Confluence, Bamboo, Fisheye
Why to automate Programmers hate menial tasks Faster and cleaner project setup Continous integration Consistency and repeatability Scales better Removes human errors form build process
What to automate Packaging Deployment Testing
Build automation Different build tools Ant Ivy Maven Gradle
Ant http://ant.apache.org/ Started with the command ant build.xml Complex and verbose Strictly for build scripts
Targets <target name="compile"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes"/> </target> <target name="a"/> <target name="b" depends="a"/>
Ivy Dependency management XML based <ivy-module version="2.0"> <info organisation="apache" module="hello-ivy"/> <dependencies> <dependency org= commons-lang" name="commons-l <dependency org="commons-cli" name="commons-cli" </dependencies> </ivy-module>
Eclipse project without good project build automation <classpathentry kind="lib" path="war/web- INF/lib/spring-context-4.1.1.RELEASE.jar" sourcepath="lib/sources/spring-context-sources- 4.1.1.RELEASE.jar"/> <dependency name="spring-framework" rev= 4.1.1.RELEASE"> <artifact name="springcontext" type="runtime" ext="jar" /> <dependency /> Download and upload the jar Hope Eclipse doesn t break
Maven 2004 Its heart is the pom.xml file Describes all the project details Versions, dependencies, resources, structure Still uses XML Standardised
Dependency management Auto resolves dependencies Describe what libraries you need Automatically finds the necessary.jars http://mvnrepository.com/
dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.0</version> <type>jar</type> <scope>test</scope> <optional>true</optional> </dependency>... </dependencies>
Standard Directory Layout src/main/java src/main/resources src/main/filters src/main/webapp src/test/java src/test/resources LICENSE.txt NOTICE.txt README.txt Application/Library sources Application/Library resources Resource filter files Web application sources Test sources Test resources Project's license Notices and attributions Project's readme
Flexibility Full control Dependencies Conventions Plugins Groovy with Ant
Gradle Previous tools combined Groovy DSL Scripts are code Gradle wrapper No XML
http://gradle.org/
Success stories Netflix Android apps Ticketmaster LinkedIn Unity Ebay
Hello world task hello { dolast { println 'Hello world!' } } Output of gradle -q hello > gradle -q hello Hello world!
Dependency management Can resolve maven and ivy repositories Uses similar coordinates system to maven and ivy Put version in the filename Need to automate Resolve version conflicts
repositories { mavencentral() } dependencies { compile group: 'commons-collections', name: 'commonscollections', version: '3.2' compile org.apache.tomcat:servlet-api:6.0.35' testcompile group: 'junit', name: 'junit', version: '4.+' } compile runtime testcompile testruntime
Gradle Plugins Expand project features Add different tasks (compile, test) Extend the Gradle model Add dispersion of dependancies Add new methods and variables
jar { Publishing artifacts basename = tvt_test' version = '0.0.1' from('config') { include 'application.properties' } } apply plugin: 'maven' uploadarchives { repositories { mavendeployer { repository(url: "file://localhost/tmp/myrepo/") } }
Java plugin apply plugin: java By default uses maven structure https://docs.gradle.org/current/userguide/java_plu gin.html
Simple java project buildscript { } repositories { mavencentral() } apply plugin: java' task wrapper(type: Wrapper) { } gradleversion = "2.7"
Project layout Directory src/main/java src/main/resources src/test/java src/test/resources src/sourceset/java src/sourceset/resources Meaning Production Java source Production resources Test Java source Test resources Java source for the given source set Resources for the given source set
Eclipse support Ant support built in For maven m2e Plugin For Gradle http://groovy.codehaus.org/eclipse+plugin
IntelliJ Has built in support for grade Should use for all new projects Easy to setup a new project
Demo time https://github.com/kristjant/tvt
Thank you! Questions and awnsers Contact: kristjan.talvar@nortal.com