Netbeans IDE has the concept of "J2SE Platform" which is the jdk being used by the project. That's used for compilation, running,debugging, code completion etc. All defined platforms are dumped into the NB_USERDIR/build.properties and the project's properties file has platform.active property. In the build script the active property is used to find the path to the tools.
When sharing the project, each user needs to have the same IDs of the platform so that the platform.active value gets a match.
It should work in similar manner for maven projects. The challenge here is to make it:
- shareable across multiple users/computers
- working in both netbeans and headless builds.
Usecases:
- user never sets explicit platform. It will always build with the version of jdk that maven/IDE is started with. It always builds, even when shareable. Unless someone uses jdk 1.5 features and tries to build with 1.4.
- user has an explicit jdk to build against. the compiler executable parameter is set, resolves to an existing value or maybe not. It was set manually by the user, the IDE should accomodate.
- user sets the jdk (platform) to use from within the IDE. IDE sets everything so that it's shareable and for other users helps with resolving the problems (with missing platform)
What is influenced:
- compilation - in order to compile with a certain jdk, one needs to set the executable parameter to the compiler plugin. if such a parameter is set we can try matching it against the existing defined j2se platforms in the IDE.
- running/debugging using the same base as compilation, unless explicitly changed.
- code completion should always give suggestion according to the platform selected.
- dependencies with system scope are quite nasty, the systemPath property needs to be absolute path. Without it resolving correctly, the project fails to load completely. I have a workaround for that already.
possible solutions:
- Antish solution
list of platforms in settings.xml (when to set/update?? - probably during the lifetime of the IDE, but users can run multiple netbeans instances with different settings/userdirs.. now we have 1-to-many relationship. the ant projects have the same problem?)
This probably means set of properties pointing to the jdk roots.
the active platform is set into pom.xml as property ("active.platform"). it's value is the reference to the property defined in the setting.
Then the pom contains some generic values at compiler plugin which use the activated platform property to find the javac.
- Mavenish solution
Create a shareable profile in pom.xml named netbeans-public and a user private profile in profiles.xml named netbeans-private. These would be activated when run within the IDE. Of course the user can explicitly activate them for all the builds (headless). The netbeans-public profile would define the java-plugin configuration by referencing properties that would be created in the netbeans-private profile. That way the public one is shareable, but keeps the important environment dependent bits private. At the same time the default headless build is not touched, unless explicitly required by the user.
