Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

The Art of the Builds

559 views

Published on

Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/14ehor2.

Hans Dockter presents an in-depth treatment of build systems concepts. Filmed at qconsf.com.

Hans Dockter is the founder of Gradle and Gradleware. He is a thought leader in the field of project automation and has successfully been in charge of numerous large-scale enterprise builds.

Published in: Technology

The Art of the Builds

  1. 1. Hans Dockter CEO, Gradleware Founder Gradle hans.dockter@gradleware.com The Art Of Builds
  2. 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /build-system-concepts
  3. 3. Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide Presented at QCon San Francisco www.qconsf.com
  4. 4. Executional Model
  5. 5. <target name="jar" depends="foo"> <mkdir dir="build/jar"/> <jar destfile="build/HelloWorld.jar" basedir="build/classes"> <manifest> <attribute name="Main-Class" value="oata.HelloWorld"/> </manifest> </jar> </target> task myDist(type: Jar) { from jar, "readme.txt", "distributionDir" } assemble.dependsOn myDist // This wiring could be done automatically
  6. 6. <project> [...] <build> [...] <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <configuration> <descriptors> //even more lines of code in the assemble descriptor <descriptor>src/main/assembly/src.xml</descriptor> </descriptors> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> [...] </project>
  7. 7. Integration Tests (5 mins) Jar Documentation (5 mins) Distribution Generate License Key (1 sec)
  8. 8. <target name="dist" depends=“integrationTests, docs, jar, key”> ... </target> <target name="distDE" depends=“integrationTests, docs, jar, key”> ... </target> docs.shouldRunAfter integrationTests
  9. 9. Upload Check Build
  10. 10. upload.mustRunAfter checks
  11. 11. Start Local Server Stop Local Server Integration Tests
  12. 12. <target name="integrationTestAll" depends=“startServer, integrationTests, stopServer”> ... </target> integrationTests.finalizedBy stopServer
  13. 13. IMPERATIVe!
  14. 14. Declarative
  15. 15. <project> [...] <packaging>war</packaging> [...] </project>
  16. 16. -src --main ---java --integrationTests ---java
  17. 17. Separate Project
  18. 18. Failsafe
  19. 19. Frameworkitis!
  20. 20. apply plugin: 'war'
  21. 21. sourceSets { integTest { java.srcDir file('src/integration-test/java') resources.srcDir file('src/integration-test/resources') compileClasspath = sourceSets.main.output + configurations.integTest runtimeClasspath = output + compileClasspath } }
  22. 22. // integration test plugin configurations { integTest.extendsFrom testRuntime } sourceSets { integTest { java.srcDir file('src/integration-test/java') resources.srcDir file('src/integration-test/resources') compileClasspath = sourceSets.main.output + configurations.integTest runtimeClasspath = output + compileClasspath } } task integrationTest(type: Test) { group = 'verify' testClassesDir = sourceSets.integTest.output.classesDir classpath = sourceSets.integTest.runtimeClasspath } check.dependsOn integrationTest apply plugin: 'java' apply plugin: 'integration-test' dependencies { [...] integTest "xmlunit:xmlunit:3.0" }
  23. 23. apply plugin: 'java' apply plugin: 'integration-test' dependencies { [...] integTest "xmlunit:xmlunit:3.0" }
  24. 24. apply plugin: 'java' apply plugin: 'integration-test' integrationTests { db { maxParallelForks = 1 } ui { maxParallelForks = 4 } } // integration test plugin // define integrationTests declarative element … ...
  25. 25. apply plugin: 'android' android { compileSdkVersion 15 flavorGroups "abi", "version" productFlavors { arm { flavorGroup "abi" } x86 { flavorGroup "abi" } free { flavorGroup "version" packageName = "com.android.tests.flavored.free" versionName = "2.0.0-free" } paid { flavorGroup "version" packageName = "com.android.tests.flavored.paid" versionName = "1.0.0-paid" } } }
  26. 26. Android tasks ------------- androidDependencies - Displays the Android dependencies of the project signingReport - Displays the signing info for each variant Build tasks ----------- assemble - Assembles all variants of all applications and secondary packages. [assembleArmFree, assembleArmPaid, assembleDebug, assembleRelease, assembleX86Free, assembleX86Paid] assembleArmFree - Assembles all builds for flavor ArmFree [assembleArmFreeDebug, assembleArmFreeRelease] assembleArmFreeDebug - Assembles the Debug build for flavor ArmFree compileArmFreeDebug compileArmFreeDebugAidl compileArmFreeDebugRenderscript dexArmFreeDebug generateArmFreeDebugBuildConfig mergeArmFreeDebugAssets mergeArmFreeDebugResources packageArmFreeDebug prepareArmFreeDebugDependencies processArmFreeDebugJavaRes processArmFreeDebugManifest processArmFreeDebugResources validateDebugSigning assembleArmFreeRelease - Assembles the Release build for flavor ArmFree compileArmFreeRelease compileArmFreeReleaseAidl compileArmFreeReleaseRenderscript dexArmFreeRelease generateArmFreeReleaseBuildConfig mergeArmFreeReleaseAssets mergeArmFreeReleaseResources packageArmFreeRelease prepareArmFreeReleaseDependencies processArmFreeReleaseJavaRes processArmFreeReleaseManifest processArmFreeReleaseResources assembleArmFreeTest - Assembles the Test build for the ArmFreeDebug build compileArmFreeDebug compileArmFreeDebugAidl compileArmFreeDebugRenderscript compileArmFreeTest compileArmFreeTestAidl compileArmFreeTestRenderscript dexArmFreeTest generateArmFreeDebugBuildConfig generateArmFreeTestBuildConfig mergeArmFreeDebugAssets mergeArmFreeDebugResources mergeArmFreeTestAssets mergeArmFreeTestResources packageArmFreeTest prepareArmFreeDebugDependencies prepareArmFreeTestDependencies processArmFreeDebugManifest processArmFreeDebugResources processArmFreeTestJavaRes processArmFreeTestResources processArmFreeTestTestManifest validateDebugSigning assembleArmPaid - Assembles all builds for flavor ArmPaid [assembleArmPaidDebug, assembleArmPaidRelease] assembleArmPaidDebug - Assembles the Debug build for flavor ArmPaid compileArmPaidDebug compileArmPaidDebugAidl compileArmPaidDebugRenderscript dexArmPaidDebug generateArmPaidDebugBuildConfig mergeArmPaidDebugAssets mergeArmPaidDebugResources packageArmPaidDebug prepareArmPaidDebugDependencies processArmPaidDebugJavaRes processArmPaidDebugManifest processArmPaidDebugResources validateDebugSigning assembleArmPaidRelease - Assembles the Release build for flavor ArmPaid compileArmPaidRelease compileArmPaidReleaseAidl compileArmPaidReleaseRenderscript dexArmPaidRelease generateArmPaidReleaseBuildConfig mergeArmPaidReleaseAssets mergeArmPaidReleaseResources packageArmPaidRelease prepareArmPaidReleaseDependencies processArmPaidReleaseJavaRes processArmPaidReleaseManifest processArmPaidReleaseResources assembleArmPaidTest - Assembles the Test build for the ArmPaidDebug build compileArmPaidDebug compileArmPaidDebugAidl compileArmPaidDebugRenderscript compileArmPaidTest compileArmPaidTestAidl compileArmPaidTestRenderscript dexArmPaidTest generateArmPaidDebugBuildConfig generateArmPaidTestBuildConfig mergeArmPaidDebugAssets mergeArmPaidDebugResources mergeArmPaidTestAssets mergeArmPaidTestResources packageArmPaidTest prepareArmPaidDebugDependencies prepareArmPaidTestDependencies processArmPaidDebugManifest processArmPaidDebugResources processArmPaidTestJavaRes processArmPaidTestResources processArmPaidTestTestManifest validateDebugSigning assembleDebug - Assembles all Debug builds [assembleArmFreeDebug, assembleArmPaidDebug, assembleX86FreeDebug, assembleX86PaidDebug] assembleRelease - Assembles all Release builds [assembleArmFreeRelease, assembleArmPaidRelease, assembleX86FreeRelease, assembleX86PaidRelease] assembleTest - Assembles all the Test applications [assembleArmFreeTest, assembleArmPaidTest, assembleX86FreeTest, assembleX86PaidTest] assembleX86Free - Assembles all builds for flavor X86Free [assembleX86FreeDebug, assembleX86FreeRelease] assembleX86FreeDebug - Assembles the Debug build for flavor X86Free compileX86FreeDebug compileX86FreeDebugAidl compileX86FreeDebugRenderscript dexX86FreeDebug generateX86FreeDebugBuildConfig mergeX86FreeDebugAssets mergeX86FreeDebugResources packageX86FreeDebug prepareX86FreeDebugDependencies processX86FreeDebugJavaRes processX86FreeDebugManifest processX86FreeDebugResources validateDebugSigning assembleX86FreeRelease - Assembles the Release build for flavor X86Free compileX86FreeRelease compileX86FreeReleaseAidl compileX86FreeReleaseRenderscript dexX86FreeRelease generateX86FreeReleaseBuildConfig mergeX86FreeReleaseAssets mergeX86FreeReleaseResources packageX86FreeRelease prepareX86FreeReleaseDependencies processX86FreeReleaseJavaRes processX86FreeReleaseManifest processX86FreeReleaseResources assembleX86FreeTest - Assembles the Test build for the X86FreeDebug build compileX86FreeDebug compileX86FreeDebugAidl compileX86FreeDebugRenderscript compileX86FreeTest compileX86FreeTestAidl compileX86FreeTestRenderscript dexX86FreeTest generateX86FreeDebugBuildConfig generateX86FreeTestBuildConfig mergeX86FreeDebugAssets mergeX86FreeDebugResources mergeX86FreeTestAssets mergeX86FreeTestResources packageX86FreeTest prepareX86FreeDebugDependencies prepareX86FreeTestDependencies processX86FreeDebugManifest processX86FreeDebugResources processX86FreeTestJavaRes processX86FreeTestResources processX86FreeTestTestManifest validateDebugSigning assembleX86Paid - Assembles all builds for flavor X86Paid [assembleX86PaidDebug, assembleX86PaidRelease] assembleX86PaidDebug - Assembles the Debug build for flavor X86Paid compileX86PaidDebug compileX86PaidDebugAidl compileX86PaidDebugRenderscript dexX86PaidDebug generateX86PaidDebugBuildConfig mergeX86PaidDebugAssets mergeX86PaidDebugResources packageX86PaidDebug prepareX86PaidDebugDependencies processX86PaidDebugJavaRes processX86PaidDebugManifest processX86PaidDebugResources validateDebugSigning assembleX86PaidRelease - Assembles the Release build for flavor X86Paid compileX86PaidRelease compileX86PaidReleaseAidl compileX86PaidReleaseRenderscript dexX86PaidRelease generateX86PaidReleaseBuildConfig mergeX86PaidReleaseAssets mergeX86PaidReleaseResources packageX86PaidRelease prepareX86PaidReleaseDependencies processX86PaidReleaseJavaRes processX86PaidReleaseManifest processX86PaidReleaseResources assembleX86PaidTest - Assembles the Test build for the X86PaidDebug build compileX86PaidDebug compileX86PaidDebugAidl compileX86PaidDebugRenderscript compileX86PaidTest compileX86PaidTestAidl compileX86PaidTestRenderscript dexX86PaidTest generateX86PaidDebugBuildConfig generateX86PaidTestBuildConfig mergeX86PaidDebugAssets mergeX86PaidDebugResources mergeX86PaidTestAssets mergeX86PaidTestResources packageX86PaidTest prepareX86PaidDebugDependencies prepareX86PaidTestDependencies processX86PaidDebugManifest processX86PaidDebugResources processX86PaidTestJavaRes processX86PaidTestResources processX86PaidTestTestManifest validateDebugSigning build - Assembles and tests this project. [assemble, check] buildDependents - Assembles and tests this project and all projects that depend on it. [build] buildNeeded - Assembles and tests this project and all projects it depends on. [build] clean - Deletes the build directory. Help tasks ---------- dependencies - Displays all dependencies declared in root project 'flavors'. dependencyInsight - Displays the insight into a specific dependency in root project 'flavors'. help - Displays a help message projects - Displays the sub-projects of root project 'flavors'. properties - Displays the properties of root project 'flavors'. tasks - Displays the tasks runnable from root project 'flavors' (some of the displayed tasks may belong to subprojects). Install tasks ------------- installArmFreeDebug - Installs the Debug build for flavor ArmFree compileArmFreeDebug compileArmFreeDebugAidl compileArmFreeDebugRenderscript dexArmFreeDebug generateArmFreeDebugBuildConfig mergeArmFreeDebugAssets mergeArmFreeDebugResources packageArmFreeDebug prepareArmFreeDebugDependencies processArmFreeDebugJavaRes processArmFreeDebugManifest processArmFreeDebugResources validateDebugSigning installArmFreeTest - Installs the Test build for the ArmFreeDebug build compileArmFreeDebug compileArmFreeDebugAidl compileArmFreeDebugRenderscript compileArmFreeTest compileArmFreeTestAidl compileArmFreeTestRenderscript dexArmFreeTest generateArmFreeDebugBuildConfig generateArmFreeTestBuildConfig mergeArmFreeDebugAssets mergeArmFreeDebugResources mergeArmFreeTestAssets mergeArmFreeTestResources packageArmFreeTest prepareArmFreeDebugDependencies prepareArmFreeTestDependencies processArmFreeDebugManifest processArmFreeDebugResources processArmFreeTestJavaRes processArmFreeTestResources processArmFreeTestTestManifest validateDebugSigning installArmPaidDebug - Installs the Debug build for flavor ArmPaid compileArmPaidDebug compileArmPaidDebugAidl compileArmPaidDebugRenderscript dexArmPaidDebug generateArmPaidDebugBuildConfig mergeArmPaidDebugAssets mergeArmPaidDebugResources packageArmPaidDebug prepareArmPaidDebugDependencies processArmPaidDebugJavaRes processArmPaidDebugManifest processArmPaidDebugResources validateDebugSigning installArmPaidTest - Installs the Test build for the ArmPaidDebug build compileArmPaidDebug compileArmPaidDebugAidl compileArmPaidDebugRenderscript compileArmPaidTest compileArmPaidTestAidl compileArmPaidTestRenderscript dexArmPaidTest generateArmPaidDebugBuildConfig generateArmPaidTestBuildConfig mergeArmPaidDebugAssets mergeArmPaidDebugResources mergeArmPaidTestAssets mergeArmPaidTestResources packageArmPaidTest prepareArmPaidDebugDependencies prepareArmPaidTestDependencies processArmPaidDebugManifest processArmPaidDebugResources processArmPaidTestJavaRes processArmPaidTestResources processArmPaidTestTestManifest validateDebugSigning installX86FreeDebug - Installs the Debug build for flavor X86Free compileX86FreeDebug compileX86FreeDebugAidl compileX86FreeDebugRenderscript dexX86FreeDebug generateX86FreeDebugBuildConfig mergeX86FreeDebugAssets mergeX86FreeDebugResources packageX86FreeDebug prepareX86FreeDebugDependencies processX86FreeDebugJavaRes processX86FreeDebugManifest processX86FreeDebugResources validateDebugSigning installX86FreeTest - Installs the Test build for the X86FreeDebug build compileX86FreeDebug compileX86FreeDebugAidl compileX86FreeDebugRenderscript compileX86FreeTest compileX86FreeTestAidl compileX86FreeTestRenderscript dexX86FreeTest generateX86FreeDebugBuildConfig generateX86FreeTestBuildConfig mergeX86FreeDebugAssets mergeX86FreeDebugResources mergeX86FreeTestAssets mergeX86FreeTestResources packageX86FreeTest prepareX86FreeDebugDependencies prepareX86FreeTestDependencies processX86FreeDebugManifest processX86FreeDebugResources processX86FreeTestJavaRes processX86FreeTestResources processX86FreeTestTestManifest validateDebugSigning installX86PaidDebug - Installs the Debug build for flavor X86Paid compileX86PaidDebug compileX86PaidDebugAidl compileX86PaidDebugRenderscript dexX86PaidDebug generateX86PaidDebugBuildConfig mergeX86PaidDebugAssets mergeX86PaidDebugResources packageX86PaidDebug prepareX86PaidDebugDependencies processX86PaidDebugJavaRes processX86PaidDebugManifest processX86PaidDebugResources validateDebugSigning installX86PaidTest - Installs the Test build for the X86PaidDebug build compileX86PaidDebug compileX86PaidDebugAidl compileX86PaidDebugRenderscript compileX86PaidTest compileX86PaidTestAidl compileX86PaidTestRenderscript dexX86PaidTest generateX86PaidDebugBuildConfig generateX86PaidTestBuildConfig mergeX86PaidDebugAssets mergeX86PaidDebugResources mergeX86PaidTestAssets mergeX86PaidTestResources packageX86PaidTest prepareX86PaidDebugDependencies prepareX86PaidTestDependencies processX86PaidDebugManifest processX86PaidDebugResources processX86PaidTestJavaRes processX86PaidTestResources assembleArmFreeRelease compileArmFreeRelease compileArmFreeReleaseAidl compileArmFreeReleaseRenderscript dexArmFreeRelease generateArmFreeReleaseBuildConfig mergeArmFreeReleaseAssets mergeArmFreeReleaseResources packageArmFreeRelease prepareArmFreeReleaseDependencies processArmFreeReleaseJavaRes processArmFreeReleaseManifest processArmFreeReleaseResources > 300 Tasks
  27. 27. A Rich Model
  28. 28. Demo Deep IDE integration
  29. 29. http://gradlesummit.com Gradle Summit 2015 June 11-12 Santa Clara, CA, USA
  30. 30. Build Logic & Imperativeness
  31. 31. <target name="main" depends="foo" > <groovy> @Grab('org.codehaus.groovy.modules:groovyws:0.5.1') import groovyx.net.ws.WSClient def url = 'http://www.w3schools.com/webservices/tempconvert.asmx?WSDL' def proxy = new WSClient(url, this.class.classLoader) proxy.initialize() ant.echo "I'm freezing at ${properties.celsius} degrees" properties.result = proxy.CelsiusToFahrenheit(properties.celsius) </groovy> <antcall target="results"/> </target> task generateMountainFiles << { def outputDir = mkdir("$buildDir/mountains") def mountains = new XmlSlurper().parse(file("src/mountains.xml")) mountains.mountain.each { mountain -> def mountainFile = new File(outputDir, mountain.name.text() + ".txt") mountainFile.text = "feet:${mountain.height.text()}" } }
  32. 32. task generateMountainFiles(type: ConvertMountainXml) { outputDir = "$buildDir/mountains" as File xmlFile = file("src/mountains.xml") separator = ":" } class ConvertMountainXml extends DefaultTask { @InputFile File xmlFile @Input String separator @OutputDirectory File outputDir @TaskAction public void generate() { def mountains = new XmlSlurper().parse(xmlFile) mountains.mountain.each { mountain -> def mountainFile = new File(outputDir, mountain.name.text() + ".txt") mountainFile.text = "feet$separator${mountain.height.text()}" } } }
  33. 33. http://m.gradleware.com http://gradleware.com/subscribe http://www.gradle.org
  34. 34. http://gradleware.com/services
  35. 35. Hans Dockter CEO, Gradleware Founder Gradle hans.dockter@gradleware.com Questions?
  36. 36. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/build- system-concepts

×