Hi,
I’m trying to convert getFeaturesXml task I have defined in my build.gradle script below into a groovy class which extends from DefaultTask, so I can use it in my custom gradle plugin.
Here’s the task definition in build.gradle:
task getFeaturesXml << {
copy {
configurations.featuresXml.filter{it.toString().endsWith(".jar")}.each{
from( zipTree(it) )
}
include 'features.xml'
into workingDir
}
}
Here’s how I’m trying to port it into a groovy class:
package com.iqnavigator.migration
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.TaskAction
class GetFeaturesXmlTask extends DefaultTask
{
def featuresXmlConfiguration
public def setFeaturesXmlConfiguration(def value)
{
featuresXmlConfiguration = value
}
@TaskAction
void run()
{
copy {
featuresXmlConfiguration.filter{it.toString().endsWith(".jar")}.each{
from( project.zipTree(it) )
}
include 'features.xml'
into workingDir
}
}
}
Obviously, “copy” is not recognized from within GetFeaturesXmlTask class. I tried to use new Copy(), but how do I specify this closure within it?
{
featuresXmlConfiguration.filter{it.toString().endsWith(".jar")}.each{
from( project.zipTree(it) )
}
Any help will be much appreciated.
Thanks! Dmitriy.