Plugin needs Gradle to be installed

Answered

I want to start IntelliJ in headless mode to analyse projects. Therefore i created a plugin (using the template). When starting i want to load all files and that required libraries are loaded. Therefore i already implemented:

 

Project project = projectManager.loadAndOpenProject(projectPath);
StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> {

 

To wait to index all files. Now i want gradle to load all dependencies:

 

ProjectSystemId projectSystemId = new ProjectSystemId("GRADLE");
//ProjectSystemId projectSystemId = new ProjectSystemId("MAVEN");

ExternalSystemUtil.refreshProject(
        project,
        projectSystemId,
        project.getProjectFilePath(),
        null, // Passing null for the callback since there's no direct callback in this method
        false,
        ProgressExecutionMode.MODAL_SYNC
);

 

 

But this gives me an error:

Plugin 'Formatter' requires plugin 'com.intellij.gradle' to be installed.

 

I already added the dependency in my plugin.xml: 

<depends>com.intellij.gradle</depends>

 

And in my build.gradle.kts:
intellij {
    version.set("2023.2")
    type.set("IC") // Target IDE Platform

    plugins.set(listOf("java", "com.intellij.java", "com.intellij.gradle"))
}

 

So this is where i am currently stuck and did not find any answers. 

 

This is my project: https://github.com/NilsBaumgartner1994/REDCLIFF-Java

0
10 comments

Thank you for the quick reaction. I will have a look into this :-)

0

The problem still exists:

 

build.gradle.kts:
intellij {
    version.set("2023.1.3")
    type.set("IC") // Target IDE Platform

    plugins.set(listOf("java", "com.intellij.java", "org.jetbrains.plugins.gradle"))
}

 

Plugin.xml:

<depends>org.jetbrains.plugins.gradle</depends>

 

Code:

import org.jetbrains.plugins.gradle.util.GradleConstants;

ExternalSystemUtil.refreshProjects(new ImportSpecBuilder(project, GradleConstants.SYSTEM_ID));

 

Error: 

 The Formatter (id=com.funbiscuit.idea.plugin.formatter, path=/app/idea/plugins/formatter-plugin) plugin Plugin 'Formatter' requires plugin 'org.jetbrains.plugins.gradle' to be installed

0

I have removed the line from the plugin.xml:
<depends>org.jetbrains.plugins.gradle</depends>

 

Which gives me an error when trying to use: GradleConstants.SYSTEM_ID

but probably brings me a step further?

 

ProjectSystemId projectSystemId = new ProjectSystemId("GRADLE");
System.out.println("refreshProject start");
ExternalSystemUtil.refreshProject(
        project,
        projectSystemId,
        project.getProjectFilePath(),
        new ExternalProjectRefreshCallback() {
            public void onSuccess() {
                System.out.println("Project dependencies synchronized successfully.");

                JavaFileAnalyzer analyzer = new JavaFileAnalyzer(project);
                analyzer.analyze();
            }

            public void onFailure(@NotNull String errorMessage, @NotNull String errorDetails) {
                System.err.println("Failed to synchronize project dependencies: " + errorMessage);
                LOG.error("Failed to synchronize project dependencies: " + errorDetails);
            }
        }, // Passing null for the callback since there's no direct callback in this method
        false,
        ProgressExecutionMode.MODAL_SYNC
);

 

Now i am getting the error:

java.lang.IllegalArgumentException: Can't retrieve local external system settings for id 'Gradle'. Reason: no such external system is registered

0

Sorry my previous answer was wrong, removed it. You MUST keep the same dependency ID in your plugin.xml, please follow the docs https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html

com.intellij.gradle ID is correct and must work, just double-checked. Make sure to sync/refresh your Gradle project after changing your Gradle build file.

Please remove "java" and keep only valid com.intellij.java as dependency.

0

Okay i added in plugin.xml

<depends>com.intellij.gradle</depends>

 

and in build.gradle.kts:

intellij {
    version.set("2023.1.3")
    type.set("IC") // Target IDE Platform

    plugins.set(listOf("com.intellij.java", “com.intellij.gradle”))
}

 

I also removed “java”

 

Unfortunately i still receive the error:

plugin Plugin 'Formatter' requires plugin 'com.intellij.gradle' to be installed

0

do i need to put something anything else in the dependencies in build.gradle.kts?

dependencies {
    implementation("info.picocli:picocli:4.7.4")
}

0

So, have you disabled the Gradle plugin in your sandbox? There is nothing else required in your setup as explained  on the linked page.

0

Where may i check this? I am using a Dockerfile, do i have to check it there or in which file?

 

In my Dockerfile I load the latest IntelliJ IDEA and install the plugin there.

FROM ubuntu:jammy-20230624

WORKDIR /app

RUN apt-get update \
  && apt-get install -y unzip wget libfreetype6 fontconfig \
  && rm -rf /var/lib/apt/lists/*

RUN wget https://download.jetbrains.com/idea/ideaIC-2023.1.3.tar.gz \
    && tar -xzf ideaIC-2023.1.3.tar.gz \
    && rm ideaIC-2023.1.3.tar.gz \
    && mv idea-* idea \
    && cd idea \
    && mv plugins plugins-old \
    && mkdir plugins \
    && cp -r plugins-old/java plugins-old/java-ide-customization plugins-old/keymap-* plugins \
    && rm -r plugins-old

WORKDIR /app/idea

COPY build/distributions/formatter-plugin plugins/formatter-plugin

COPY formatter /usr/bin/formatter

WORKDIR /data

ENTRYPOINT ["formatter"]
 

0

The problem seemed to be as you said, that the gradle plugin was removed. Here is the complete Dockefile now:

 

FROM ubuntu:jammy-20230624

WORKDIR /app

# Install necessary packages
RUN apt-get update \
  && apt-get install -y unzip wget libfreetype6 fontconfig \
  && rm -rf /var/lib/apt/lists/*

# Download and extract IntelliJ IDEA
RUN wget https://download.jetbrains.com/idea/ideaIC-2023.1.3.tar.gz \
    && tar -xzf ideaIC-2023.1.3.tar.gz \
    && rm ideaIC-2023.1.3.tar.gz \
    && mv idea-* idea

# Set the working directory to /app/idea for plugin operations
WORKDIR /app/idea

# Download and install the Gradle plugin for IntelliJ IDEA
RUN wget -O gradle-intellij-plugin.zip "https://plugins.jetbrains.com/plugin/download?rel=true&updateId=410281" \
    && mkdir -p plugins/gradle-intellij-plugin \
    && unzip gradle-intellij-plugin.zip -d plugins/gradle-intellij-plugin \
    && rm gradle-intellij-plugin.zip

# Copy your custom plugin and formatter
COPY build/distributions/formatter-plugin plugins/formatter-plugin
COPY formatter /usr/bin/formatter

# Set the working directory back to /data
WORKDIR /data

ENTRYPOINT ["formatter"]
 

 

I will test if i need to redownload the gradle Plugin at: # Download and install the Gradle plugin for IntelliJ IDEA

Anyway a HUUUGE thank you Yann Cebron. Hoping to show my results at the IDE Workshop :-)

0

I am facing a new problem:

com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkException: Invalid Gradle JDK configuration found. <a href='#open_external_system_settings'>Open Gradle Settings</a>

 

But i will think we might just “close” this problem as the original one was with the Dockerfile removing the gradle plugin in the sandbox

0

Please sign in to leave a comment.