Reputation: 45
task('copytask', type: Copy) {
def SRC_FOLDER = "$rootDir"
def DEST_FOLDER = 'C:\\Users\\IdeaProjects\\destfolder'
copy {
from("$SRC_FOLDER\\controller\\app")
into("$DEST_FOLDER\\controller\\app")
}
}
This is my small Gradle task to copy. Whenever I am reloading/refreshing my Gradle or starting my IDEA this task is executing, i want this task to execute only when I call it.
Upvotes: 0
Views: 686
Reputation: 14543
Your task is not really executing. Instead, your task is getting configured, but during configuration you are copying using the copy
method of the Project
instance. Your actual task copytask
of type Copy
remains unconfigured and won't do anything, even if it would be executed.
Change your code and remove the copy
method and the files should only be copied when running the task copytask
:
task('copytask', type: Copy) {
def SRC_FOLDER = "$rootDir"
def DEST_FOLDER = 'C:\\Users\\IdeaProjects\\destfolder'
from("$SRC_FOLDER\\controller\\app")
into("$DEST_FOLDER\\controller\\app")
}
Upvotes: 2