List of Listings

Chapter 1. Introduction to project automation

Listing 1.1. Ant script with targets for compiling source code and assembling JAR file

Listing 1.2. Maven POM for building standardized Java project

Chapter 2. Next-generation builds with Gradle

Listing 2.1. Dynamic task definition and task chaining

Chapter 3. Building a Gradle project by example

Listing 3.1. The repository interface

Listing 3.2. In-memory persistence of to-do items

Listing 3.3. Implementing the main class

Listing 3.4. Changing properties and adding a JAR header

Listing 3.5. Changing the project default layout

Chapter 4. Build script essentials

Listing 4.1. Applying task dependencies

Listing 4.2. Representing the project version by a POGO

Listing 4.3. Writing a task configuration

Listing 4.4. Switching the project version to production-ready

Listing 4.5. Adding incremental build support via inputs/outputs

Listing 4.6. Custom task implementation

Listing 4.7. Task of type ReleaseVersionTask

Listing 4.8. Different version POGO implementation

Listing 4.9. Setting individual property values for task makeReleaseVersion

Listing 4.10. Using task types to back up a zipped release distribution

Listing 4.11. Declaring tasks for incrementing version classifiers

Listing 4.12. Merging similar logic into a task rule

Listing 4.13. Release version functionality implemented as lifecycle hook

Listing 4.14. Release version functionality implemented as lifecycle listener

Chapter 5. Dependency management

Listing 5.1. Defining a configuration for Cargo libraries

Listing 5.2. Accessing the cargo configuration by name

Listing 5.3. Assigning Cargo dependencies to cargo configuration

Listing 5.4. Excluding a single dependency

Listing 5.5. Excluding all transitive dependencies

Listing 5.6. Declaring a dependency on the latest Cargo 1.x version

Listing 5.7. Copying the Cargo dependencies to your local file system

Listing 5.8. Declaring file dependencies

Listing 5.9. Declaring a custom Maven repository

Listing 5.10. Declaring an Ivy repository

Listing 5.11. Cargo dependencies declaration retrieved from a flat directory repository

Listing 5.12. Printing the concatenated file path of all Cargo dependencies

Chapter 6. Multiproject builds

Listing 6.1. Settings file that adds subproject by path

Listing 6.2. Defining project-specific build logic

Listing 6.3. Declaring project dependencies

Listing 6.4. Cross-project task definition without dependencies

Listing 6.5. Declaring cross-project task dependencies

Listing 6.6. Configuring common project behavior

Listing 6.7. The root project’s build.gradle file

Listing 6.8. The build.gradle file of the repository subproject

Listing 6.9. The build.gradle file of the web subproject

Listing 6.10. Settings file defining custom project script names

Chapter 7. Testing with Gradle

Listing 7.1. Writing a test class using JUnit

Listing 7.2. Declaring a dependency on JUnit in subproject repository

Listing 7.3. Enabling test support for TestNG

Listing 7.4. Using Spock to write and execute unit tests

Listing 7.5. Configuring build to execute JUnit, TestNG, and Spock tests

Listing 7.6. Test report aggregation

Listing 7.7. Evaluating system property to drive test execution

Listing 7.8. Providing system properties and JVM parameters

Listing 7.9. Logging standard streams to the terminal

Listing 7.10. Displaying exception stack traces

Listing 7.11. Logging specific test events

Listing 7.12. Configuring forked test processes

Listing 7.13. Execute code after test suite is executed

Listing 7.14. Adding a test listener to the default test task

Listing 7.15. Testing H2 database persistence code

Listing 7.16. Defining a task for running integration tests

Listing 7.17. Defining a source set for integration tests

Listing 7.18. Declaring functional test configurations and dependencies

Listing 7.19. Functional test source set

Listing 7.20. Using the source set in the functionalTest task

Listing 7.21. Declaring enhanced Jetty tasks for use with functional tests

Listing 7.22. Integrating functional test tasks into build lifecycle

Chapter 8. Extending Gradle

Listing 8.1. Adding the CloudBees API library to the build script’s classpath

Listing 8.2. Writing a task to list an available application on CloudBees account

Listing 8.3. Writing a task for deploying a WAR file

Listing 8.4. Custom task for retrieving application information

Listing 8.5. Build script in buildSrc directory

Listing 8.6. Consuming the custom task

Listing 8.7. Simplifying CloudBees interaction by introducing a parent task class

Listing 8.8. Simplified custom task

Listing 8.9. Testing the custom task CloudBeesAppInfo using ProjectBuilder

Listing 8.10. Applying the tomcat plugin available on Maven Central

Listing 8.11. Implementing the plugin interface

Listing 8.12. Providing a plugin DSL for capturing user input

Listing 8.13. Plugin extension POGO

Listing 8.14. Registering and using an extension

Listing 8.15. Using properties set by convention mapping

Listing 8.16. Assigning a short identifier for plugin

Listing 8.17. Using the plugin short identifier

Listing 8.18. Writing a test for the plugin implementation class

Listing 8.19. Build script of standalone plugin project

Listing 8.20. Using the object plugin from the web project

Chapter 9. Integration and migration

Listing 9.1. Original Ant build script

Listing 9.2. Adding behavior to existing Ant target functionality

Listing 9.3. Seamless interaction between Ant and Gradle builds

Listing 9.4. Defining inputs and outputs for imported Ant target

Listing 9.5. Using the standard Get Ant task

Listing 9.6. Declaring compilation dependencies

Listing 9.7. Custom provided configuration

Listing 9.8. Maven profile file defining application server home directories

Listing 9.9. Reading environment-specific property from settings file

Listing 9.10. Original Maven POM file

Listing 9.11. Generated Gradle build script

Listing 9.12. Generated Gradle settings file

Listing 9.13. Upgrading the Gradle runtime

Chapter 10. IDE support and tooling

Listing 10.1. Setting root project properties

Listing 10.2. Setting JDT and classpath properties for all subprojects

Listing 10.3. Fine-tuning the Eclipse properties of the web subproject

Listing 10.4. Adding the WTP JavaScript facet using the XML hook

Listing 10.5. Adding the WTP JavaScript facet using a merge hook

Listing 10.6. Setting root project properties

Listing 10.7. Setting module properties for all subprojects

Listing 10.8. Adding the custom source set for the repository subproject

Listing 10.9. Adding custom source set and configurations for the web subproject

Listing 10.10. Preconfiguring project settings with the XML hook

Listing 10.11. Preconfiguring project settings using a merge hook

Listing 10.12. Applying the Sublime Text plugin to all projects of your build

Listing 10.13. Tweaking the configuration of Sublime Text project files

Listing 10.14. CloudBees task for retrieving application information

Listing 10.15. Preparing the integration tests

Listing 10.16. Integration testing using the tooling API

Chapter 11. Building polyglot projects

Listing 11.1. Using dependency management for consuming JavaScript libraries

Listing 11.2. Declaring dependency on Google Closure Compiler library

Listing 11.3. Calling Google Closure Compiler Ant task

Listing 11.4. Using custom task for minifying JavaScript

Listing 11.5. Conditional packaging and use of optimized JavaScript files

Listing 11.6. Declaring Rhino and JSHint dependencies

Listing 11.7. Executing the JSHint JavaScript with Rhino from Gradle

Listing 11.8. Adding the JavaScript plugin to the build script’s classpath

Listing 11.9. Configuring the JavaScript plugin

Listing 11.10. Task that installs Grunt dependencies via npm

Listing 11.11. Custom task for calling Grunt executable

Listing 11.12. Enhanced task executing the Grunt JSHint plugin

Listing 11.13. Activating the compiler daemon

Listing 11.14. Using Groovy to manage production source code

Listing 11.15. ToDoItem model class written in Groovy

Listing 11.16. Customizing the default Groovy source set directories

Listing 11.17. Repository interface written in Groovy

Listing 11.18. Reconfiguring source sets for joint compilation

Listing 11.19. Using Scala to manage production source code

Listing 11.20. ToDoItem model class written in Scala

Listing 11.21. Customizing the default Scala source set directories

Listing 11.22. Reconfiguring source sets for joint compilation

Chapter 12. Code quality management and monitoring

Listing 12.1. Defining the JaCoCo plugin as script plugin

Listing 12.2. Applying the JaCoCo script plugin to all subprojects

Listing 12.3. Defining the Cobertura plugin as script plugin

Listing 12.4. Applying the Cobertura script plugin to all subprojects

Listing 12.5. Preparing subprojects for the integration of static code analysis plugins

Listing 12.6. Task for generating HTML reports via XSLT

Listing 12.7. Applying and configuring the Checkstyle plugin as script plugin

Listing 12.8. Applying Checkstyle to all subprojects

Listing 12.9. Generating a Checkstyle HTML report for all source sets

Listing 12.10. Applying and configuring the PMD plugin as script plugin

Listing 12.11. Configuring the generated PMD report type

Listing 12.12. Applying and configuring the FindBugs plugin as script plugin

Listing 12.13. Applying and configuring the JDepend plugin as script plugin

Listing 12.14. Applying and configuring the Sonar Runner plugin

Listing 12.15. Adding custom source sets for analysis

Listing 12.16. Configuring Sonar Runner plugin to reuse Cobertura reports

Chapter 14. Artifact assembly and publishing

Listing 14.1. Declaring additional artifacts

Listing 14.2. Building a distribution

Listing 14.3. Configuring a custom distribution

Listing 14.4. Publishing JAR component to a Maven repository

Listing 14.5. Generated POM for published software component

Listing 14.6. Publishing additional artifacts to a Maven repository

Listing 14.7. Publishing additional artifacts to a Maven repository

Listing 14.8. Modified plugin POM

Listing 14.9. Publishing to a local Maven repository

Listing 14.10. Publishing to a remote Maven repository

Listing 14.11. Publishing to Bintray repository

Listing 14.12. Consuming the published plugin from Bintray

Listing 14.13. Groovy class representing the project version

Listing 14.14. Setting build information as script plugin

Listing 14.15. Providing the version to all projects of the build

Listing 14.16. Including build information in a WAR file

Listing 14.17. Publishing to a remote Maven repository

Chapter 15. Infrastructure provisioning and deployment

Listing 15.1. Custom task for executing Vagrant commands

Listing 15.2. Enhanced tasks for important Vagrant commands

Listing 15.3. Groovy-based, environment-specific configuration

Listing 15.4. Reading configuration during configuration phase

Listing 15.5. Using the configuration extra property

Listing 15.6. Adding binary repository settings to buildConfig.groovy

Listing 15.7. Downloading the WAR file from a remote repository

Listing 15.8. Custom task wrapping the optional Ant SCP task

Listing 15.9. Transferring the WAR file to the server via SCP

Listing 15.10. Custom task wrapping the optional Ant SSH task

Listing 15.11. SSH commands for managing Tomcat and deploying WAR file

Listing 15.12. Build script for buildSrc project

Listing 15.13. Custom task for executing HTTP smoke tests

Listing 15.14. Smoke tests for verifying HTTP URLs

Listing 15.15. Task for exercising functional tests against remote servers

Appendix B. Groovy for Gradle users

Listing B.1. Gradle task written with Java syntax

Listing B.2. Gradle task written with Groovy syntax

Listing B.3. A typical Java POJO class

Listing B.4. Project version class written in Groovy

Listing B.5. Groovy’s power assert

Listing B.6. Optional typing for variables and methods

Listing B.7. Omitting parentheses for top-level expressions

Listing B.8. String notations in Groovy

Listing B.9. String interpolation with GStrings

Listing B.10. Managing Lists in Groovy

Listing B.11. Managing Maps in Groovy

Listing B.12. Setting field values with named parameters

Listing B.13. Closure with single, implicit parameter

Listing B.14. Closure with single, explicit parameter

Listing B.15. Closure with multiple, untyped parameters

Listing B.16. Closure return value

Listing B.17. Closure as method parameter

Listing B.18. Setting the delegate for a closure

Listing B.19. Examples of methods added by the GDK

Listing B.20. Applied Groovy syntax in a sample Gradle build script

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.162.247