Sunday Jul 15, 2012

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.

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 2012 »
SunMonTueWedThuFriSat
14
28
29
30
31
    
       
Today