When I run ./gradlew bootRun, I'd like for the npmInstall task that it depends on to run with the "--force" or "--legacy-peer-deps" arguments.
I tried using ./gradlew bootRun npm_install_--force but this doesn't make the npm install task that runs before the bootRun task use the --force argument. How can I pass either one of these arguments to the npmInstall task?
I'm running on windows and I need either one of these arguments so that I can resolve angular dependency issues. The npm version is 8.19.2
You should be able to create an .npmrc file with the following contents to solve this:
legacy-peer-deps=true
Related
I know that if in Gradle I use: build -x test it builds and the test are not executed.
In STS with Buildship for support with Gradle, for example for Spring Integration
It has the following two tasks of my interest (build and test):
I can build with the following:
Because some test fails (randomly) I want skip the tests, so I tried
it fails with:
So I tried with:
And fails with
And with:
Nothing happens, only shows the following and stopping:
So how represent build -x test correctly with Buildship?
You must supply -x test as Program Arguments like this:
Or you just run assemble instead of build. assemble is a lifecycle task that aggregates all archive tasks in the project and, besides other tasks, does not execute check tasks, such as test.
I want to use the Gradle Tooling API to invoke Gradle from an Eclipse plugin through the Buildship plug-ins. I am able to run basic tasks without problems.
One of my use cases is to execute the gradle init task in a new project folder, but to work non-interactively I have to pass the --type command line argument (or set the type property) on the init task. I can't find any way in the tooling API to set the properties of a task or to pass a task-specific command line argument.
I have tried BuildLauncher.addArgument("--type", "plain") but this is interpreted as an argument to Gradle itself, which is invalid.
How can I pass the --type plain argument to the init task?
After reading the docs here, I discovered you can set the task arguments via the Gradle command line build arguments. The important bit in the docs is:
Also, the task names configured by BuildLauncher.forTasks(String...) can be overridden if you happen to specify other tasks via the build arguments.
In my case I wanted to run gradle tasks --all via the tooling api. To get this working, I don't specify the task to run via forTasks(), I simply do not call that method. I set the task to run as part of the arguments via withArguments(). (In this case the arguments will be tasks --all).
I assume this should work the same for the init task.
Gradle 4.9 introduced the --args parameter to bootRun, which I can use easily from the command-line, but how do I use this from a Run/Debug configuration in Intellij 2018?
With a Gradle build set to run the bootRun task on my project in Intellij, I've tried the following arguments in the Run/Debug Configurations screen without any success:
--args 'foo'
--args='foo'
--args=foo
Output from Intellij:
9:18:56 AM: Executing task 'bootRun --args='foo''...
Unknown command-line option '--args'.
9:18:57 AM: Task execution finished 'bootRun --args='foo''.
A similar question documents the older syntax for doing this.
Maybe you can add your args to Tasks as bootRun --args='foo' in IDEA's Run/Debug Configurations.
My task is run --args='-h' and it works for me
Unfortunately, #Linsama's workaround will not work with multiple arguments. For example, run --args='--arg1 --arg2' will not work.
For multiple arguments, you have to move the entire thing in the Arguments field and leave the Tasks field blank.
This will work:
Tasks:
Arguments: run --args='--arg1 --arg2'
As a workaround you can use gradle properties.
In intellij Arguments field add -Pargs=--myArg=value
Then in your build.gradle add
bootRun {
if (project.hasProperty('args')) {
args project.args.split(',')
}
}
They should be now accesible using ApplicationArguments inside your application.
I'm using gradle-node-plugin to help reduce dependencies for my project. Gradlew is basically replacing grunt or gulp in my project. This makes java my only dependency.
Before, I'd use npm run tsc and I had an npm task that would run tsc -w but now that npm is a gradle plugin, I can't call npm directly. I have the following task in my build.gradle:
task watch(dependsOn: 'npmInstall', type: NpmTask) {
outputs.upToDateWhen { false }
args = ['run', 'tsc']
}
Technically it works. It first makes sure that the npm plugin has installed all it's pieces (including typescript) and then will run my tsc task. The problem is that tsc -w never terminates. It watches my files for changes until I choose to terminate it. It does this successfully, but gradle constantly reports that the task is Building 75% > :watch. I have another task in package.json that offers up my files in an http-server and it behaves in the same way.
Is there a preferred way to have gradle run a never ending task like this or should I just let it think it's perpetually building?
I'm looking for a syntax along the lines of ./gradlew :all:myTask that I can quickly execute from the command line. I must have missed it in the documentation somewhere.
I know I can modify the build to include a new task that runs a task against all sub-projects, however I'd prefer to not mess with modifying the build for simple one-off scenarios.
If I understand your goal correctly, running ./gradlew myTask should do what you want by default
:myTask
:foo:myTask
:foo:bar:myTask
:baz:myTask