How can I restore source/resource folder icons with a custom Gradle layout?

Answered

I'm setting up a Gradle project using the following configuration to adjust my project layout:

sourceSets {
    main.groovy.srcDirs = ['src']
    main.resources.srcDirs('conf', 'resources')
    test.groovy.srcDirs = ['test']
}

 However, the directories in the project panel look like this: 

Instead of this:

Is there anything I can do to get the correct icons back?

Thanks,

Kevin

0
6 comments
This is expected behavior. When IntelliJ IDEA registers a folder as a source root (whether through Gradle, Maven, or a manual project structure setting), it replaces the plain folder icon with a type-specific icon: blue for source roots, green for test roots, and so on. There is no setting to revert to a plain folder icon while the folder is still marked as a source root.

If you'd like this to be an option, you can file a feature request on our issue tracker at https://youtrack.jetbrains.com in the IntelliJ Platform project.
0

When IntelliJ IDEA registers a folder as a source root (whether through Gradle, Maven, or a manual project structure setting), it replaces the plain folder icon with a type-specific icon: blue for source roots, green for test roots, and so on.

This is exactly the behaviour I want, however, I don't get the blue or green icons. I just get the icons representing modules and a description of the folder next to it. Is this the expected behaviour you're referring to?

0

Kshep92 Sorry that my last reply was based on a misread. Could you please share your IntelliJ IDEA version (Help | About)?

What you're seeing is related to how the Gradle import places the content root when you use a non-standard srcDirs path. When srcDirs points directly at a top-level directory like `code`, IntelliJ ends up treating that folder as both the module content root and the source root at the same time. In that situation it renders the content-root presentation (the folder-with-badge icon and the grey "sources root" label) instead of the plain solid-colored source-root folder.

A fix for this was shipped in IntelliJ IDEA 2024.3 in IDEA-163185, so if you're on an older version, upgrading should restore the colored icon. If you're already on 2024.3 or later, let us know and we can take a closer look at your build.gradle.

0

Bond Han Kindly see below my version information:

IntelliJ IDEA 2026.1.2
Build #IU-261.24374.151, built on May 14, 2026
Source revision: fa0cfa150836c
Runtime version: 25.0.2+1-b329.117 amd64137.0.17-261-b81
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 10.0
Exception reporter ID: 2907251ee22c30a-67f5-4020-872f-764cc7ace935
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Registry:
 ide.experimental.ui=true
 llm.chat.default.agent.rollout.enabled=true
 trace.state.event.service.url=https://api.jetbrains.cloud/trace-status
 llm.selector.config.refresh.interval=10
 editor.ux.survey.enabled=false
 llm.rules.refresh.interval=10
Non-Bundled Plugins:
 com.intellij.java (261.24374.151)
 org.jetbrains.junie (261.1755.48)
 org.jetbrains.completion.full.line (261.24374.151)
 JavaScriptDebugger (261.24374.151)
 lechuck.intellij-plugin.task (1.7.2)
 Batch Scripts Support (1.0.13)
 org.jetbrains.plugins.vue (261.24374.154)
 com.dmarcotte.handlebars (261.22158.180)
 com.github.bjansen.intellij.pebble (v0.11.0)
 com.intellij.ml.llm (261.24374.208)
 org.jetbrains.plugins.hocon (2026.1.2)
Kotlin: 261.24374.151-IJ

My build.gradle settings are as follows:

plugins {
   id 'idea'
   id 'groovy'
}
version = '0.0.1'
repositories {
   mavenCentral()
   maven { url 'https://repo.gradle.org/gradle/libs-releases' }
}
sourceSets {
   main.groovy.srcDirs = ['code']
   main.resources.srcDirs('conf', 'resources')
   test.groovy.srcDirs = ['test']
}
// Dependencies and tasks
0

Kshep92 Thanks! This looks different. I have logged this as a separate bug: IDEA-390303 You can follow it for updates by clicking the star icon on the issue page. This article explains the options: https://intellij-support.jetbrains.com/hc/en-us/articles/207241135 Also please feel free to add any comments there in YouTrack.

0

Thanks very much Bond Han I'll follow the issue there.

0

Please sign in to leave a comment.