[GRADLE-271] Linking tasks with dependency configurations should not be a part of dependencies (linkConfWithTask) Created: 22/Oct/08  Updated: 04/Jan/13  Resolved: 07/Apr/09

Status: Resolved
Project: Gradle
Affects Version/s: 0.4
Fix Version/s: 0.6

Type: Improvement
Reporter: Martin Vlcek Assignee: Hans Dockter
Resolution: Fixed Votes: 0

Issue Links:
Related
Related to GRADLE-183 Dependency Layer Refactoring Resolved

 Description   

The dependency definition should be independent of the tasks.
Rather some tasks are dependent on a specific dependency configuration, thus this should be defined within the task:

Instead of
dependencies

{ addConfiguration("client") linkConfWithTask('client', 'clientCompile') ... }

createTask('clientCompile', type: Compile)

{ ... }

it should rather be
dependencies

{ addConfiguration('client') ... }

createTask('clientCompile', type: Compile)

{ configurations = [ 'client' ] ... }

Reasons:

  • currently there is a static dependency from dependencies {...}

    to the tasks (linkConfWithTask), while the execution dependency is in the other direction - bad

  • in future dependencies will/might be read from external files (ivy.xml) - the link to the tasks can't be in the ivy.xml - would there still be a dependencies { linkConfWithTask... }

    ?

  • (!!!) readability - everybody should see on the first glance, what a specific compile or other task does and which configuration it uses.


 Comments   
Comment by Martin Vlcek [ 23/Oct/08 ]

For better readability one can use the following lines:

createTask('clientCompile', type: Compile) {
project.dependencies.linkConfWithTask 'client', name
...
}

This should at least be simplified by adding a method linkWithConf(String... confName) to the (relevant) tasks, thus allowing to specify:

createTask('clientCompile', type: Compile) {
linkWithConf 'client'
...
}

This is a trivial change supporting both ways to define dependencies without changing the current architecture of gradle.

BTW: isn't it "link sth. TO sth."?

Comment by Hans Dockter [ 25/Oct/08 ]

Have a look at http://jira.codehaus.org/browse/GRADLE-183 (which also contains a link to a discussion about this issue on the dev list).

Comment by Hans Dockter [ 07/Apr/09 ]

We have now a different, much nicer, mechanism. A configuration has now a property buildDependencies which returns a task.

What you can do now is to say:

createTask('myTask', dependsOn: configurations.runtime.buildDependencies) {
   ...
}

If runtime has project dependencies, those projects are now build before myTask is executed.

Generated at Wed Jun 30 11:25:56 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.