Hello
I’m thinking this is a bug. I’m using Gradle 2.9. I cannot get the from() to work in a Sync closure. I also tried a copySpec ant if fails as well. I would expect that in a sync closure you could Specify From or use a copySpec.
When running with a copySpec I get this error
MissingMethodException: Could not find method with() for arguments [org.gradle.api.internal.file.copy.DefaultCopySpec_Decorated@6d6f5770] on task
When I use from
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method from() for arguments [docroot]
You might be asking why I just don’t use Task type:Sync. The reason is that with Liferay it modifies CSS content on the fly. I’m trying to keep incremental builds working. So my hope was to sync the source CSS to a temporary location. I then run the Liferay CSS processor on that temp location. It will generate files within that temp location. (Note there is no possible option to change the output directory). Now when I re-run the build, it will notice that the inputs have NOT changed so the sync will not re-run despite the fact that the target directory was modified earlier.
Attempt 1
task sassCssToBuildDir { // The inputs to this are the souce code files, if any of them changem re-process the CSS inputs.files fileTree("docroot") { include "**/_diffs/**" include "**/.sass-cache*/**" include "**/.sass_cache_*/**" include "**/_sass_cache_*/**" include "**/_styled/**" include "**/_unstyled/**" } outputs.dir "${buildDir}/pluginSassCssTemp" doLast () { //If any change to the source css, just wipe it and resync it sync { from('docroot') include "**/_diffs/**" include "**/.sass-cache*/**" include "**/.sass_cache_*/**" include "**/_sass_cache_*/**" include "**/_styled/**" include "**/_unstyled/**" into "${buildDir}/sassCSSTemp" } } }
Attempt 2
task sassCssToBuildDir {
// The inputs to this are the souce code files, if any of them changem re-process the CSS
inputs.files fileTree(“docroot”) {
include “/_diffs/”
include “/.sass-cache*/”
include “/.sass_cache_*/”
include “/sass_cache*/”
include “/_styled/”
include “/_unstyled/”
}
def sassCSSCopySpec = copySpec { from('docroot') include "**/_diffs/**" include "**/.sass-cache*/**" include "**/.sass_cache_*/**" include "**/_sass_cache_*/**" include "**/_styled/**" include "**/_unstyled/**" }
outputs.dir "${buildDir}/pluginSassCssTemp" doLast () { //If any change to the source css, just wipe it and resync it sync { with sassCSSCopySpec into "${buildDir}/sassCSSTemp" } } }
I also tried
sync { from('docroot') { include "**/_diffs/**" include "**/.sass-cache*/**" include "**/.sass_cache_*/**" include "**/_sass_cache_*/**" include "**/_styled/**" include "**/_unstyled/**" into "${buildDir}/sassCSSTemp" }