How do I migrate “yarn run-script build” task from frontend-maven-plugin to gradle?
How do I migrate “yarn run-script build” task from frontend-maven-plugin to gradle?
I use gradle-node-plugin instead of frontend-maven-plugin.
"yarn run-script build" task in maven is written such as following
<execution>
<id>yarn run-script build</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<arguments>build</arguments>
<environmentVariables>
<buildDir>$project.build.directory/classes/static</buildDir>
</environmentVariables>
</configuration>
</execution>
In gradle, I wrote yarnScriptBuild task
task yarnScriptBuild(type: YarnTask, dependsOn: yarnTest)
group 'Node'
args = ['run', 'build']
If I did "./gradlew yarnScriptBuild" command,
I got the error "Output path MUST not be project root directory!"
Then I inserted outputs.dir = ("$buildDir/classes") to yarnScriptBuild,but it didn't work.
(I found the page "$buildDir means root directory/build" few days ago)
I got another error "No such property: dir for class: org.gradle.api.internal.tasks.DefaultTaskOutputs"
outputs.dir = ("$buildDir/classes")
Does this mean that "dir" property isn't exist?
How should I do? What is missing?
If information lacks, please let me know.
Thank you.
1 Answer
1
Try configuring the yarnWorkDir and nodeWorkDir in NodeExtension :
yarnWorkDir
nodeWorkDir
NodeExtension
NodeExtension node = project.extensions.getByType(NodeExtension.class)
node.with
nodeModulesDir = $pathToDirWithNodeModulesDir
yarnWorkDir = $pathToYarnJs
also, you might want to fix your outputs path to this:
outputs
outputs.dir = project.file("$buildDir/classes")
outputs.dir = project.file("$buildDir/classes")
or this:
output.dir "$buildDir/classes"
output.dir "$buildDir/classes"
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.