How to suppress warning messages in the console when running a plugin as command line?

Answered

This is a question about running an IntelliJ plugin as a command line (i.e., headless).

I have implemented an ApplicationStarter class, and in my main method, I am printing a Hello World text.

In my build.gradle.kts file I have a custom task that calls the ApplicationStarter class

To run the plugin as CLI, I created a .sh file that calls the custom gradle task. 

Running the .sh file executes the code in my ApplicationStarter class, and the Hello World text is printed in the console/command line. However, there are some system-generated warnings also printed in the console. My question is, how can I suppress these warnings?

$ ./runCLI.sh abc xyz
> Task :compileKotlin UP-TO-DATE
> Task :compileJava UP-TO-DATE
> Task :setupDependencies
> Task :patchPluginXml UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :instrumentCode UP-TO-DATE
> Task :postInstrumentCode
> Task :inspectClassesForKotlinIC UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :prepareSandbox UP-TO-DATE
> Task :buildSearchableOptions UP-TO-DATE
> Task :jarSearchableOptions UP-TO-DATE
> Task :buildPlugin UP-TO-DATE

> Task :MyCustomCli
[gradle-intellij-plugin :MyCoolPlugin:MyCustomCli] Cannot resolve runtime with ideDir='C:\Users\xxx\.gradle\caches\modules-2\files-2.1\com.jetbrains.intellij.idea\ideaIU\2021.3.2\c89a0bdb0dfd1bf1389c887e91d4a4c49858eee1\ideaIU-2021.3.2'
2022-03-01 11:16:10,078 [    360]   WARN - llij.ide.plugins.PluginManager - id redefinition ([row,col,system-id]: [2,3,"product classpath"])
Hello World!! This text is from the plugin!
2022-03-01 11:16:14,719 [   5001]   WARN - l.NotificationGroupManagerImpl - Notification group CodeWithMe is already registered (group=com.intellij.notification.NotificationGroup@431409fd). Plugin descriptor: PluginDescriptor(name=Code With Me, id=com.jetbrains.codeWithMe, descriptorPath=plugin.xml, path=~\.gradle\caches\modules-2\files-2.1\com.jetbrains.intellij.idea\ideaIU\2021.3.2\c89a0bdb0dfd1bf1389c887e91d4a4c49858eee1\ideaIU-2021.3.2\plugins\cwm-plugin, version=213.6777.52, package=null, isBundled=true)

BUILD SUCCESSFUL in 11s
14 actionable tasks: 3 executed, 11 up-to-date

In the above output, how can I suppress the printing of the following messages:

  • Cannot resolve runtime with ideDir....
  • WARN - llij.ide.plugins.PluginManager - id....
  • WARN - l.NotificationGroupManagerImpl...

 

The following is the code in my .sh file:

#!/usr/bin/env bash

if [ $# -ne "2" ]; then
echo "usage: generate-dataset <path to project> <path to output folder>"
exit 1
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
if uname -s | grep -iq cygwin ; then
DIR=$(cygpath -w "$DIR")
PWD=$(cygpath -w "$PWD")
fi

"$DIR/gradlew" --console=plain -p "$DIR" MyCustomCli -Pinput="$1" -Poutput="$2"

 

1 comment
Comment actions Permalink

Are you using latest gradle-intellij-plugin 1.4.0? There's unfortunately nothing you can do about the WARN entries AFAIU.

0

Please sign in to leave a comment.