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 configurationbuildDependents
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 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
removed |
|
removed |
|
|
|
|
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 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
War convention property changes
0.7 |
0.8 |
|---|---|
|
|
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 tofrom(). You can pass this method any of the types supported byProject.files(). This includesFileinstances,Stringfile names, anyFileCollectionorFileTreeimplementation, or collections of these objects.
0.7 |
0.8 |
|---|---|
Compile task
- The
srcDirsproperty has been replaced by thesrcproperty. You can pass this method any of the types supported byProject.files().
0.7 |
0.8 |
|---|---|
- Compiler args are set differently now:
0.7 |
0.8 |
|---|---|
GroovyCompile task
- The
groovyJavaIncludesandgroovyIncludesproperties have been merged intoincludes. - The
groovyJavaExcludesandgroovyExcludesproperties have been merged intoexcludes. - The
groovySourceDirsandsrcDirsproperties have been replaced by thesrcproperty.
0.7 |
0.8 |
|---|---|
Javadoc task
- The
srcdirsproperty has been replaced by thesrcproperty. - The
excludesproperty now takes a set of Ant-style exclude patterns, rather than package names. - The
configurationproperty has been renamed toclasspath. - The
sourcepath,subpackagesandpackagenamesproperties have been removed. They have been replaced byincludeandexcludeproperties.
Groovydoc task
- The
srcDirsproperty has been replaced by the {{src} property. - The
packageNamesproperty has been replaced by theincludeproperty.
Test task
- The
configuationproperty has been renamed toclasspath.
JettyRun task
- The
classesDirectoryandconfigurationproperty of theJettyRuntask have merged into a singleclasspathproperty.
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:
FileCollectionCopySpecCopyAction
The LogLevel.log() methods have been replaced by the Logger interface, accessible from Logging.getLogger().
CopyActionImpl.globalExcludes has moved to PatternSet.
