This is a list of some of the breaking changes from 0.5 to 0.6.
Dependency and Artifact Handling Changes
In 0.6 repository and configuration declarations have been moved out of the dependencies configuration closure. See below for some details.
See UG 21 and UG 22 for all the changes.
Task Changes
The createTask() method has been deprecated and will be removed in a later release. It has been replaced by the task() method. The following shows a couple of common cases:
0.5 |
0.6 |
|---|---|
| |
|
One imporant thing to note here is that when you provide a closure when you define a task, the closure is now treated as a configuration closure, and executed at configuration time. In 0.5 it was treated as a task action, and executed at execution time.
For code which defines tasks programatically, you should now use the add() method on TaskContainer to define tasks. See TaskContainer for details.
See UG 4 and UG 12 for more examples.
Repositories
Repositories are no longer declared inside dependencies closure, but inside a repositories closure. See the javadoc for RepositoryHandler for details on the methods allowed here. Note that the parameters to the methods for adding repositories now take a Map. Here are some examples and how they differ from 0.5 to 0.6.
0.5 |
0.6 |
|---|---|
| |
|
Configurations
Custom configurations are no longer declared inside of the dependencies closure, but inside of a configurations closure. New configurations can be created by simply referencing them as shown:
0.5 |
0.6 |
|---|---|
| |
|
project.configurations now returns a ConfigurationContainer
so:
0.5 |
0.6 |
|---|---|
| |
|
Tasks
project.tasksnow returns a TaskContainer rather than a Map.org.gradle.api.tasks.Resourcesrenamed toCopy.- Methods
task(path)andfindTask(path)have been replaced withtasks.getByPath(path)andtasks.findByPath(path).
Java Plugin
Some task have been renamed:
Old Name |
New Name |
|---|---|
testCompile |
compileTests |
resources |
processResources |
testResources |
processTestResources |
archive_jar |
jar |
archive_war |
war |
In addition, the way you specify additional archives has changed. Both the libs and dists tasks are now simple tasks, and you add an additional archives by defining a task with type Jar, Zip, War, or Tar:
0.5 |
0.6 |
|---|---|
| |
|
When you add a JAR or WAR archive, it becomes a dependency of the libs task. When you add a ZIP or TAR archive, it becomes a dependency of the dists task.
Property archivesBaseName has been moved from Project to BasePluginConvention. That this means that you must set this property only after applying the Java/Groovy/War plugin. It will have no effect if you set it before applying the plugin.
Jetty Plugin
- The
jettyRunExplodedtask has been removed. systemPropertieshas been removed from the Jetty tasks.useTestClasspath,testClassesDirandtestConfigurationhave been removed fromJettyRuntask.
Project
Various changes to the Project interface:
- Method
getBuildFileName()has been replaced withgetBuildFile() - Method
addAfterEvaluateListener(Closure)has been renamed toafterEvaluate(Closure) - Method
addAfterEvaluateListener(AfterEvaluateListener)has been replaced byafterEvaluate(ProjectAction). You can also useBuild.afterProject(Action)andBuild.addProjectEvaluateListener(ProjectEvaluateListener) - Property
archivesTaskBaseNamehas been removed.
Settings Script
ProjectDescriptor.getDir()andsetDir()have been renamed togetProjectDir()andsetProjectDir()
Misc
org.gradle.api.tasks.util.FileCollectionhas been removed. It has been replaced byorg.gradle.api.artifacts.FileCollection
