Skip to end of metadata
Go to start of metadata

Usage

Java Plugin Tasks

The jar task no longer depends on the test task. In multiproject builds, the tests in depended on projects will not be required to run in order to build up the artifacts.

Three new tasks have been added:

  • build
    Builds all artifacts, runs unit tests, and code style checks for a single project.
  • buildNeeded
    Runs build on a project and on all projects with a project lib dependency in its testRuntime configuration
  • buildDependents
    Runs build on a project and on all projects that depend on it.

See the "Multi-Project Building and Testing" section of the userguide for more information.

The compileTests task has been renamed to compileTestJava. A new testClasses task has been added which is a replacement for compileTests.

The compile task has been renamed to compileJava. A new classes task has been added which is a replacement for compile.

The libs and dists tasks have been merged into a single assemble task.

Groovy Plugin Tasks

The compile task has been split into compileJava and compileGroovy. The compileJava task uses javac to compile all the Java source in src/main/java. The compileGroovy task uses groovyc to compile all the Groovy and Java source in src/main/groovy.

A similar change has been made to the compileTests task. It has been split into compileTestJava and compileTestGroovy.

Command-line options

Command-line option -f has been renamed to -S.
Command-line option -I now specifies an init script. You can use --no-imports instead.

Build Scripts

The build property has been renamed gradle.

Main classes are now compiled into $buildDir/classes/main
Test classes are now compiled into $buildDir/classes/test

Use of FileSet is deprecated. Use Project.fileTree() instead.

Skip properties no longer supported

Skip properties for tasks are no longer supported. This means you can no longer use -Dskip.someTask to skip a task. Instead, you can exclude individual tasks using the -x command line option:

gradle -xtest -xdocs build

You can add skip properties support to your build script if you like, using the following:

Java convention property changes

Many of the properties used to configure the locations of resource and Java source have changed. Below are some examples:

0.7

0.8

srcDirs

sourceSets.main.java.srcDirs

srcDirsNames << 'somedir'

sourceSets.main.java.srcDir 'src/somedir'

floatingSrcDirs << file('somedir')

sourceSets.main.java.srcDir file('somedir')

resourceDirs

sourceSets.main.resources.srcDirs

resourceDirsNames << 'somedir'

sourceSets.main.resources.srcDir 'src/somedir'

floatingResourceDirs << file('somedir')

sourceSets.main.resources.srcDir file('somedir')

testSrcDirs

sourceSets.test.java.srcDirs

testSrcDirNames << 'somedir'

sourceSets.test.java.srcDir 'src/somedir'

floatingTestSrcDirs << file('somedir')

sourceSets.test.java.srcDir file('somedir')

testResourceDirs

sourceSets.test.resources.srcDirs

testResourceDirNames << 'somedir'

sourceSets.test.resoures.srcDir 'src/somedir'

floatingTestResourceDirs << file('somedir')

sourceSets.test.resources.srcDir file('somedir')

classesDir

sourceSets.main.classesDir

classesDirName = 'somedir'

sourceSets.main.classesDir = 'build/somedir'

testClassesDir

sourceSets.test.classesDir

testClassesDirName = 'somedir'

sourceSets.test.classesDir = 'build/somedir'

srcRootName = 'somedir'

removed

srcRoot

removed

javadocsDir

javadoc.destinationDir

javadocsDirName = 'somedir'

javadoc.destinationDir = file('build/docs/somedir')

Groovy convention property changes

Many of the properties used to configure the locations of Groovy source have changed. Below are some examples:

0.7

0.8

groovySrcDirs

sourceSets.main.groovy.srcDirs

groovySrcDirNames << 'somedir'

sourceSets.main.groovy.srcDir 'src/somedir'

floatingGroovySrcDirs << file('somedir')

sourceSets.main.groovy.srcDir file('somedir')

groovyTestSrcDirs

sourceSets.test.groovy.srcDirs

groovyTestSrcDirNames << 'somedir'

sourceSets.test.groovy.srcDir 'src/somedir'

floatingGroovyTestSrcDirs << file('somedir')

sourceSets.test.groovy.srcDir file('somedir')

groovydocDir

groovydoc.destinationDir

groovydocDirName = 'somedir'

groovydoc.destinationDir = file("$docsDir/somedir")

War convention property changes

0.7

0.8

webAppDirName = 'somedir'

webAppDirName = 'src/somedir'

Java project configuration changes

The testCompile configuration no longer includes the main classes directory. You can use source.test.compileClasspath instead of configurations.testCompile to pick up the full test compile classpath.

You can also add the main classes directory back into the testCompile configuration:

The Java plugin no longer adds a dists configuration.

Archive tasks

  • The files() method has been renamed to from(). You can pass this method any of the types supported by Project.files(). This includes File instances, String file names, any FileCollection or FileTree implementation, or collections of these objects.

0.7

0.8

Compile task

  • The srcDirs property has been replaced by the src property. You can pass this method any of the types supported by Project.files().

0.7

0.8

  • Compiler args are set differently now:

0.7

0.8

GroovyCompile task

  • The groovyJavaIncludes and groovyIncludes properties have been merged into includes.
  • The groovyJavaExcludes and groovyExcludes properties have been merged into excludes.
  • The groovySourceDirs and srcDirs properties have been replaced by the src property.

0.7

0.8

Javadoc task

  • The srcdirs property has been replaced by the src property.
  • The excludes property now takes a set of Ant-style exclude patterns, rather than package names.
  • The configuration property has been renamed to classpath.
  • The sourcepath, subpackages and packagenames properties have been removed. They have been replaced by include and exclude properties.

Groovydoc task

  • The srcDirs property has been replaced by the {{src} property.
  • The packageNames property has been replaced by the include property.

Test task

  • The configuation property has been renamed to classpath.

JettyRun task

  • The classesDirectory and configuration property of the JettyRun task have merged into a single classpath property.

API

The Build class has been renamed to Gradle.
The Gradle class has been renamed to GradleLauncher.

Project.getBuild() has been renamed to Project.getGradle().
BuildListener.buildStarted() now accepts a Gradle parameter, rather than a StartParameters parameter.

The following interfaces have been moved to org.gradle.api.file package:

  • FileCollection
  • CopySpec
  • CopyAction

The LogLevel.log() methods have been replaced by the Logger interface, accessible from Logging.getLogger().

CopyActionImpl.globalExcludes has moved to PatternSet.

Labels: