I am trying to copy one file to multiple destinations through a Gradle task. I found the following in other websites but I get an ERROR while running this task.
def filesToCopy = copySpec{ from 'somefile.jar' rename {String fileName -> 'anotherfile.jar'} } task copyFile(type:Copy) { with filesToCopy { into 'dest1/' } with filesToCopy { into 'dest2/' } }
ERROR
No signature of method: org.gradle.api.internal.file.copy.CopySpecImpl.call() is applicable for argument types
Is there a way to copy to multiple destinations in one Gradle task?
A FileTree represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a FileTree to represent files to copy or the contents of an archive. You can obtain a FileTree instance using Project.
In Gradle, zip files can be created by using 'type: zip' in the task. In the below example, from is the path of source folder which we want to zip. destinationDir is the path of the destination where the zip file is to be created. archiveName is the name of the zip file.
The build directory of this project into which Gradle generates all build artifacts. 4. Contains the JAR file and configuration of the Gradle Wrapper.
You can do gradle -Dtest. single=ClassUnderTestTest test if you want to test single class or use regexp like gradle -Dtest. single=ClassName*Test test you can find more examples of filtering classes for tests under this link.
If you really want them in one task, you do something like this:
def filesToCopy = copySpec { from 'someFile.jar' rename { 'anotherfile.jar' } } task copyFiles << { ['dest1', 'dest2'].each { dest -> copy { with filesToCopy into dest } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With