Start with the NetBeans Paint Application and do the following to build it via Gradle (i.e., no Gradle/NetBeans plugin is needed for the following steps), assuming you've set up Gradle. Do everything below in the Files or Favorites window, not in the Projects window.
In the application directory "Paint Application". Create a file named "settings.gradle", with this content:
include 'ColorChooser', 'Paint'
Create another file in the same location, named "build.gradle", with this content:
subprojects {
apply plugin: "announce"
apply plugin: "java"
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
}
}
In the module directory "Paint". Create a file named "build.gradle", with this content:
dependencies {
compile fileTree("$rootDir/build/public-package-jars").matching { include '**/*.jar' }
}
task show << {
configurations.compile.each { dep -> println "$dep ${dep.isFile()}" }
}
Note: The above is a temporary solution, as you can see, the expectation is that the JARs are in the 'build/public-packages-jars' folder, which assumes an Ant build has been done prior to the Gradle build.
Now run 'gradle classes' in the "Paint Application" folder and everything will compile correctly.
So, this is how the Paint Application now looks:
Preferable to the second 'build.gradle' would be this, which uses the JARs found in the NetBeans Platform...
netbeansHome = '/home/geertjan/netbeans-dev-201111110600'
dependencies {
compile files("$rootDir/ColorChooser/release/modules/ext/ColorChooser.jar")
def projectXml = new XmlParser().parse("nbproject/project.xml")
projectXml.configuration.data."module-dependencies".dependency."code-name-base".each {
if (it.text().equals('org.openide.filesystems')) {
def dep = "$netbeansHome/platform/core/"+it.text().replace('.','-')+'.jar'
compile files(dep)
} else if (it.text().equals('org.openide.util.lookup') || it.text().equals('org.openide.util')) {
def dep = "$netbeansHome/platform/lib/"+it.text().replace('.','-')+'.jar'
compile files(dep)
} else {
def dep = "$netbeansHome/platform/modules/"+it.text().replace('.','-')+'.jar'
compile files(dep)
}
}
}
task show << {
configurations.compile.each { dep -> println "$dep ${dep.isFile()}" }
}
However, when you run 'gradle classes' with the above, you get an error like this:
geertjan@geertjan:~/NetBeansProjects/PaintApp1/Paint$ gradle classes
:Paint:compileJava
[ant:javac] Note: Attempting to workaround javac bug #6512707
[ant:javac]
[ant:javac]
[ant:javac] An annotation processor threw an uncaught exception.
[ant:javac] Consult the following stack trace for details.
[ant:javac] java.lang.NullPointerException
[ant:javac] at com.sun.tools.javac.util.DefaultFileManager.getFileForOutput(DefaultFileManager.java:1058)
No idea why the above happens, still trying to figure it out. Once the above works, we can start figuring out how to use the NetBeans Maven repo instead and then the user of the plugin will be able to select whether to use local JARs or JARs from the NetBeans Maven repo.
Many thanks to Hans Dockter who put the above together with me today, via Skype!