Try this:
task deploy(dependsOn : 'war') << {
copy {
from 'build/libs'
into 'C:/programs/resin-4.0.14/webapps'
include '*.war'
}
}
All I did was add "<<" before the closure. This is because your closure is
an "action" closure that doing work and needs to only be executed when the
task is run. Without the << indicates that the closure is a "configuration"
closure that will configure the task, and therefore needs to be run "soon"
(i.e. before tasks start executing). So, your "deploy" task was always
executing. To see this, put a println in it, and run some other unrelated
task. You'll see the output of the println.
A better way to do what you are doing, btw is
task deploy(dependsOn: 'war', type: Copy) {
from 'build/libs'
into 'C:/programs/resin-4.0.14/webapps'
include '*.war'
}
This time I'm using a configuration closure on purpose because I'm using the
Copy type task. With this, Gradle can now figure out what you are doing and
you get things like "smart task skipping" if Gradle realizes that your war
didn't change (for instance). Lastly, instead of hardcoding 'build/libs' as
the location the war was built into, use war.archivePath. With that, I end
up with the following:
task deploy(dependsOn: 'war', type: Copy) {
from war.archivePath
into 'C:/programs/resin-4.0.14/webapps'
}
Note that I didn't try any of this, so typos might be present, but it should
send you in the correct direction.
On Wed, Apr 20, 2011 at 4:36 PM, Potje rode kool
<[email protected]>wrote:
> Hi,
>
> I have a multi project web app project.
> One of my projects is a war project where I defined a deploy task:
>
> task deploy(dependsOn : 'war') {
> copy {
> from 'build/libs'
> into 'C:/programs/resin-4.0.14/webapps'
> include '*.war'
> }
> }
>
> When I run this deploy task I would expect that the war task would be
> executed before my deploy task copy the war file
> but this isn't the case. The war file is first copied before its build
> with my latest changes.
> Is there a way to fix this? I now execute the deploy task twice after
> I make changes.
>
> Evert
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
John Murph
Automated Logic Research Team