[GRADLE-1605] "copy" task reporting up-to-date Created: 10/Jun/11  Updated: 05/Sep/16  Resolved: 14/Jun/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-3
Fix Version/s: None

Type: Bug
Reporter: Brian Trezise Assignee: Unassigned
Resolution: Duplicate Votes: 0


 Description   

Here is the thread where the issue is discussed:
http://gradle.1045684.n5.nabble.com/Command-line-P-property-not-propagating-to-dependencies-tt4459390.html

But a brief summary follows.

Here is the affected part of my build script:

project(':api:pricing') {
	version = 1.0

	dependencies {
		compile project(':api:util')

		compile 'org.springframework:spring:2.5.6.SEC01'
		compile 'org.drools:drools-core:5.0.1'
		compile 'org.drools:drools-api:5.0.1'
		compile 'org.drools:drools-compiler:5.0.1'
	}

	task copyDatasource(type: Copy) {//copy our <datasource>.xml into dpu-datasource.xml	
		from('/datasource/')
		into('src/main/resources/')
		include(datasource + '.xml')
		rename(datasource + '.xml', 'pricing-datasource.xml')
		outputs.upToDateWhen { false } //This has no effect - With or without this, it doesn't work
	}

	jar.dependsOn task(':api:pricing:copyDataSource')
}

Basically what is happening is that if I call "gradle :api:pricing:copyDatasource" the task executes as expected; However if I call "gradle :api:pricing:jar" the copyDatasource task reports UP-TO-DATE no matter what - even if I manually delete the target file before running the build.

If I run "gradle :api:pricing:jar -i" then I get the following message when it tries to run copyDatasource -

:api:pricing:copyDataSource
Skipping task ':api:pricing:copyDataSource' as it has no actions.
:api:pricing:copyDataSource UP-TO-DATE

Assistance would be appreciated. Currently the only workaround we've got is to call the copyDatasource task directly before attempting to jar the project, which shouldn't be necessary - defeats the whole point of making jar depend on copyDatasource, and automated builds in general.

~Brian



 Comments   
Comment by Szczepan Faber [ 14/Jun/11 ]

Created a separate entry for it: GRADLE-1610

The way you refer to the task while setting the 'dependsOn' is incorrect:

//correct: you're actually creating an empty task here:
jar.dependsOn task(':foo:bar')

//correct: you refer to an existing task
jar.dependsOn ':foo:bar'

However, your example demonstrate a bug. Gradle should throw an exception saying that you cannot add ':api:pricing:copyDataSource' task because it already exists. See docs on the task method: http://gradle.org/current/docs/dsl/org.gradle.api.Project.html#org.gradle.api.Project:task(java.lang.String)

Comment by Brian Trezise [ 14/Jun/11 ]

I updated my code as you suggested, but I get the following exception with the code configured that way:

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':api:pricing:jar'.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

project(':api:pricing') {
version = 1.0

dependencies

{ compile project(':api:util') compile 'org.springframework:spring:2.5.6.SEC01' compile 'org.drools:drools-core:5.0.1' compile 'org.drools:drools-api:5.0.1' compile 'org.drools:drools-compiler:5.0.1' }

task copyDatasource(type: Copy)

{//copy our <datasource>.xml into dpu-datasource.xml from('/datasource/') into('src/main/resources/') include(datasource + '.xml') rename(datasource + '.xml', 'pricing-datasource.xml') }

jar.dependsOn ':api:pricing:copyDataSource'
}

Comment by Brian Trezise [ 14/Jun/11 ]

D'oh! Just noticed I've got some case confusion going on here! should be jar.dependsOn 'api:pricing:copyDatasource' not copyDataSource. Whoops! Thanks for the pointer on not putting it in the task('path') syntax though.

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