Notes on Gradle and NetBeans

This checks all subfolders of a folder for a file named "build.gradle". If such a file exists, the project type is created:

@org.openide.util.lookup.ServiceProvider(service = ProjectFactory.class)
public class GradleProjectFactory implements ProjectFactory {

    public final String GRADLE_BUILD_FILE = "build.gradle";

    //Specifies when a project is a project, i.e.,
    //if in the project directory "build.gradle" is present:
    @Override
    public boolean isProject(FileObject projectDirectory) {
        for (FileObject fo : projectDirectory.getChildren()) {
            if (fo.getNameExt().equals(GRADLE_BUILD_FILE)) {
                return true;
            }
        }
        return false;
    }

    ...
    ...
    ...

Actually, simpler is like this:

    @Override
    public boolean isProject(FileObject projectDirectory) {
        return projectDirectory.getFileObject(GRADLE_BUILD_FILE) != null;
    }

For the rest of the project type, go here:

http://platform.netbeans.org/tutorials/nbm-projecttype.html

For the start of a NetBeans Gradle plugin, which anyone out there is welcome to continue working on, go here:

http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.1/misc/GradleSupport

After you install the plugin, go to the Options window and register your Gradle installation.

Comments:

Thank you for the post. I wish support for Gradle in NB would be someday as good as for Ant or Maven.

Posted by guest on July 16, 2012 at 12:16 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today