Error encountered executing Gradle task from shell script
I created a class that implements "ApplicationStarter" and prints a line of text to the console in the "main" method.
My build.gradle file contains the following:
plugins {
id 'org.jetbrains.intellij' version '1.3.0'
id 'java'
}
group 'com.myplugin'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
intellij { plugins = ['java'] }
intellij {
version = '2021.2.1'
}
task runMyPlugin(dependsOn: runIde) {}
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(runMyPlugin)) {
runIde.args 'helloPlugin'
runIde.jvmArgs '-Djava.awt.headless=true'
}
}
When I run (i.e., double-click) "runMyPlugin" from the Gradle tool window, the task is executed and my code in the starter file runs.
However, my goal is to execute the Gradle task from a shell script (i.e., .sh file). Hence, I created a file with the following code:
#!/usr/bin/env bash
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" --stop
"$DIR/gradlew" clean
"$DIR/gradlew" --console=plain -p "$DIR" runMyPlugin
When I run the above bash file I encounter the following error:
A problem occurred configuring root project 'IntelliJ-Plugin-POC-Inspection'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.3.0.
Required by:
project : > org.jetbrains.intellij:org.jetbrains.intellij.gradle.plugin:1.3.0
> No matching variant of org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.3.0 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.1' but:
- Variant 'apiElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.3.0 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.1')
- Variant 'runtimeElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.3.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.1')
My operating system is Windows 10.
Appreciate some insight into resolving this issue.
Please sign in to leave a comment.
You must run with Java 11:
Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8