Slackbot
09/14/2022, 1:37 PMMartmists
09/14/2022, 1:37 PMtasks {
named<Copy>("backendProcessResources") {
val webpackTask = getByName<KotlinWebpack>(if (isDevelopment) "frontendBrowserDevelopmentWebpack" else "frontendBrowserProductionWebpack")
val jsMinifyTask = getByName("jsMinify")
val cssMinifyTask = getByName("cssMinify")
exclude(
// These files are preprocessed by the minify plugin, exclude them from the copy task
"static/js/**",
"static/css/**",
)
into("WEB-INF/") {
// TODO: Does not work, instead places into /templates as if this doesn't exist
into("templates/") {
from("templates/")
}
into("static/") {
into("js/") {
from(webpackTask.destinationDirectory)
from(jsMinifyTask) {
rename("(.*)\\.min\\.js", "$1.js")
}
}
into("css/") {
from(compileSass)
from(cssMinifyTask) {
rename("(.*)\\.min\\.css", "$1.css")
}
}
// TODO: Does not work, instead places into /static/img as if this doesn't exist
into("img/") {
from("static/img/**")
}
}
}
}
}
Niels Doucet
09/14/2022, 1:45 PMinto
returns this
, so there's no such thing as nested into
statements, they're all calling the same rootSpec.into
Niels Doucet
09/14/2022, 1:46 PMMartmists
09/14/2022, 1:49 PMthis
, doesn't it create a new copy spec for the nested block's context receiver? From the javadoc:
Creates and configures a child CopySpec with the given destination path. The destination is evaluated as per org.gradle.api.Project.file(Object).
But the main problem is that it doesn't seem to find the img and template folders, any clue what could be the issue there?Niels Doucet
09/14/2022, 1:52 PMNiels Doucet
09/14/2022, 1:54 PMfrom
and into
? I've always found that to be more intuitive to reason about. I'm not sure how the copyspec closure interprets those relative paths in such a setup.Martmists
09/14/2022, 1:56 PMinto("WEB-INF/") {
from("templates/") {
into("atemplates/") // different name to see if maybe it adds to root?
}
The files are still put into /templates, no change in behavior here.
while flipping the order can be more intuitive, having it as tree structure make the code a lot more clean imoNiels Doucet
09/14/2022, 1:58 PMfrom
sources as separate copyspecs, instead of organising by target 🤔Niels Doucet
09/14/2022, 1:59 PMfrom("templates")
to from(layout.projectDirectory.dir("templates")
, does that fix it?Martmists
09/14/2022, 1:59 PMfrom("templates") {
into("WEB-INF/templates")
}
also did not workNiels Doucet
09/14/2022, 1:59 PMMartmists
09/14/2022, 2:00 PMbut that said. If you changeWouldn't that try to target thetofrom("templates")
, does that fix it?from(layout.projectDirectory.dir("templates")
templates
folder as if it were in the project root rather than from the resources root?Niels Doucet
09/14/2022, 2:00 PMinto
isn't referencing the webpack task anywhere, right?Martmists
09/14/2022, 2:01 PMMartmists
09/14/2022, 2:04 PMNiels Doucet
09/14/2022, 2:13 PMMartmists
09/14/2022, 2:13 PMNiels Doucet
09/14/2022, 2:16 PMMartmists
09/14/2022, 2:17 PMNiels Doucet
09/14/2022, 2:35 PMfrom
closures aren't working as you expect they should. You're just seeing those files coming from inside the resources folder in the output, because that's the default configuration of the task: https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/java/org/gradle/api/plugins/JavaBasePlugin.java#L191-L192Martmists
09/14/2022, 2:36 PMNiels Doucet
09/14/2022, 2:36 PM2022-09-14T16:35:57.108+0200 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/test/templates', not found
2022-09-14T16:35:57.109+0200 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/test/static/img/**', not found
Niels Doucet
09/14/2022, 2:37 PMfrom("src/main/resources/templates")
, it just worksNiels Doucet
09/14/2022, 2:38 PMMartmists
09/14/2022, 2:38 PMNiels Doucet
09/14/2022, 2:43 PMMartmists
09/14/2022, 2:50 PMNiels Doucet
09/14/2022, 2:52 PMfrom
.Martmists
09/14/2022, 2:53 PMinto("WEB-INF")
makes it put the WEB-INF folder relative to the project root instead of the build/resources/... folderNiels Doucet
09/14/2022, 2:55 PMMartmists
09/14/2022, 2:57 PMNiels Doucet
09/14/2022, 2:59 PMMartmists
09/14/2022, 3:00 PMNiels Doucet
09/14/2022, 3:06 PMNiels Doucet
09/14/2022, 3:09 PMidea {
module {
resourceDirs.add(file("your_folder"))
}
}