netbeans-gradle-project icon indicating copy to clipboard operation
netbeans-gradle-project copied to clipboard

[Improvement] Give option of different naming for subproject's build file

Open MarceloRuiz opened this issue 8 years ago • 4 comments

Having many subprojects with a build.gradle file open in the NetBeans editor makes is really confusing. One suggestion would be to use accept a different name that includes the name of the subproject (as suggested in Gradle In Action), in the form: 'subproject.gradle' or 'subproject-build.gradle'. This upgraded name should be the default used for generating a subproject.

To allow that update, only a small change in settings.gradle is needed (this example works for both 'build.gradle' or 'subproject-build.gradle':

def subDirs = rootDir.listFiles(new FileFilter() {
        public boolean accept(File file) {
            if (!file.isDirectory()) {
                return false
            }
            if (file.name == 'buildSrc') {
                return false
            }
            if (new File(file, 'build.gradle').isFile()) {
                return true
            }
            if (new File(file, file.name.toLowerCase() + '-build.gradle').isFile()) {
                return true
            }
            return false
        }
    });

subDirs.each { File dir ->
    include dir.name
}

rootProject.children.each {
    if (! it.buildFile.isFile()) {
        it.buildFileName = it.name + '-build.gradle'
    }
}

MarceloRuiz avatar Aug 15 '16 05:08 MarceloRuiz

I assume you mean changing the project wizard. For Gradle projects, the plugin currently supports build.gradle files named as .gradle. The one you have shown might not get recognized as a Gradle project, you can only open them through their root project.

If the current options are not adequate for you, please list the name formats you expect to get support for.

kelemen avatar Aug 15 '16 14:08 kelemen

Yes, the improvement would be for the wizard for subprojects only, to make their build files stand out from other subprojects' build files. Maybe users could be presented with the default file name 'build.gradle' and have the option to add a prefix to it (the prefix could default to the subproject name, but the developer could tweak it to anything else as long as it ends in 'build.gradle').

MarceloRuiz avatar Aug 15 '16 16:08 MarceloRuiz

I guess a "-buid.gradle" suffix sounds reasonable to detect.

Anyway, you can adjust the generated settings.gradle to your liking. However, I'm not sure if I really want to adjust the wizard because then I somehow have to detect the build file name format when adding subprojects. If anything, I would rather create a new Gradle project type with a better more customizable setup where you can create subprojects using Gradle tasks.

kelemen avatar Aug 15 '16 17:08 kelemen

That would be great... If anyone is having this issue, they can replace the settings.gradle with the one I posted earlier

MarceloRuiz avatar Aug 16 '16 04:08 MarceloRuiz