Skip to content


Show the 'buildSrc' directory in the Projects tree #31

eskatos opened this Issue · 8 comments

2 participants


A Gradle project can have a 'buildSrc' directory with build related source code.


Having this directory visible in the 'Projects' tree with correct classpath set would be awesome.



Currently you can do this by manually opening the "buildSrc" project in "Open Project" (assuming it has a build.gradle). I agree that it should be displayed someway in the project view similar to other build script files (build.gradle,, ...).

What I don't want to do is to open the buildSrc project every time you open a project. My current idea is that I add a child node in the "Build Scripts" node which might be used to open "buildSrc". Also I think the project node should contain the name of the project containing buildSrc. For example: "buildSrc - MyProject", "MyProject - buidSrc" or "MyProject [build]". I'm not sure what is the best choice for the name.

Do you have any additional idea how this should look in the project view?


'buildSrc' tend to often be used without a build.gradle but we could put an empty one here to make it work though it feels a bit clumsy. Moreover the repositories and dependencies of buildSrc source code can be defined in the projects build.gradle instead of the one inside the 'buildSrc' directory.

What about a project subnode like the current "Subprojects" one but named "BuildSrc" that could be lazily loaded? It should be displayed only if a buildSrc directory is present and have sources and build scripts subnodes once loaded. WDYT?

Opening buildSrc as a first level project would be good too, I have no strong opinion about this.


You will not need an empty build.gradle if I add this feature. But with the current version of the plugin, you do, in order for the project to be recognized as a gradle project.

I'm not sure how the Tooling API of Gradle handles this if dependencies are defined somewhere else but there is little I can do about it (but if it can't, I can at least report it to Gradle devs). Can you please check what will happen if you open your buildSrc with the current version of the plugin?

I'm not sure if such lazy loading can be easily implemented in the NetBeans API, allowing you to load buildSrc (and giving you a convenient link to open it) is a lot less work to implement. Actually, if the Tooling API of Gradle supports it, it should be relatively simple to add.


I did:

touch buildSrc/build.gradle

and then opened the 'buildSrc' directory as a Gradle project.

The project opens without errors but the 'src/main/groovy' sources are not visible in the Projects view. If I open source files from there, they are displayed with errors (wrong classpath).

I'm using 1.2.0 version of the plugin.


Then I believe your only option is to manually adjust the build.gradle of buildSrc through the idea plugin. That is, you have to adjust the idea module associated with the project in order for the Tooling API to recognize the classpaths. I myself have never used buildSrc, so I'm not sure about all the possibilities but you have to find some way to gather the dependencies and manually adjust it in the idea plugin.

For example, you might do something similar to:

apply plugin: 'idea'
idea {
  module { += configurations.myconfig

This should make the NetBeans plugin recognize the dependencies added to myconfig but you might add anything else. I have never tried but it might be possible to even do this in a listener after all the projects have been evaluated.


Ok, I'll try to workaround for now and keep you posted.


I have pushed some changes to master, so now BuildSrc is added below the "Build Scripts" node of each project (if the root project has a "buildSrc"). I have decided to put this under the "Build Scripts" node because most of the time you don't want to edit the build scripts and it would take up some space if I were to add it right below the root node.

Can I ask you to try the plugin (building from master) and see if you believe something should be adjusted? Note that this won't fix your classpath issues but only makes opening buildSrc more convenient.

@kelemen kelemen closed this

Sorry for the lag, been busy.
The workaround works for fixing the classpath in the IDE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.