Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Gradle Configurations

DZone's Guide to

Gradle Configurations

Alex Jacinto reviews how to generate source code for all of your projects using Gradle, making software development easy.

· DevOps Zone
Free Resource

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.

One of the best features of Gradle is its ability to setup scaffolding for projects with common attributes.  For example, you can simply tell Gradle to generate source code for every project with a schema directory in proper location.
configure(xsdProjects()) {
    apply from: "$rootDir/gradle/jaxb.gradle"
}
def xsdProjects() {
        ext.schemaProjects = [] as Set
ext.schemaProjects.addAll subprojects.findAll { Project aProject ->
File xsdDir = new File(aProject.projectDir.path + '/src/main/resources/xsd')
xsdDir.exists()
}
ext.schemaProjects
}
Imagine working with a large code base with multiple sub projects where a handful you have to generate code from schema and few of them you have to generate from wsdl.  You can then isolate these configurations into separate files and apply them in your main build.gradle.
apply from: ‘gradle/xsd.gradle’

apply from: 'gradle/wsdl.gradle'
This setup will make the build.gradle in your sub-projects to a bare minimum.  At the most, you only need to include the sub-project description, its project dependencies and external dependencies that only apply to each.  
A very important after effect of this is that you are enforcing the conventions of your code base.  You are forcing your coworkers to put their schema and wsdl in a known place because if they don’t, they have to write all the build scripts and customize it.  In summary we are enforcing “DRY” and implementing convention over configuration.

Download the ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.

Topics:
devops ,gradle ,build

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}