Generated sources

Generated Sources


Currently we suffer by various problems related to the place where runtime tools, such as JAX-WS or JAXB, generate the sources - we call them java artifacts. Those artifacts are usually references later by classes developped by user. These are some of the problems :

  • it was not trivial to implement code completion for those java artifacts, moreover, we needed to hack particular project types to achieve that
  • the current implementation puts the java artifacts under project's build dirctory that causes various problems when project is cleaned by Clean action.
  • the java artifacts are removed
  • all references in editor become invalid (the editor is full of red lines and users don't like it)
  • any user modification (debug messages) made on those java artifacts are lost
  • Generate Javadoc action doesn't involve generated artifacts

Discussion with Netbeans Core Team

(Jesse Glick, Tomas Zezula, Milos Kleint, Milan Kubec, David Konecny, Tomas Misik, Milan Kuchtiak)

The discussion was based on the issue Issue 105645.
I asked project team to extend the Project API to enable:

  • create a special (Hidden) Sources category, that could be used for those artefacts
  • create a Project API method for adding new Source root


  • The current Project API is able to satisfy all those requirements without any modification/extension (new features in 6.0) :
  • we don't need to specify a special source root
  • to achieve the code completion, we can specify a special ClassPathProvider, and send it to projec's lookup
  • we can implement a SourceForBinaryQuery from outside the particular project types (to anable to find souce file for given class)
  • we can implement a SharabilityQuery to exclude folder from versioning

How to Proceed :

These are my ideas how to solve the problems listed above by using new Netbeans features and by implementing some changes:

  • Separate Code Completion completely from Project Types
  • specify a special ClassPathProvider and put it to project's lookup using layer.xml
  • specify a SourceForBinaryQuery and put it to project's lookup
  • Do not generate java artifacts under build/generated, but somewhere else (e.g. to project_root/java/generated). This way we achieve :
  • artifacts wan't be cleaned on every project's Clean
  • we can specify a SharabilityQuery for that folder to specify if we want to archive those files or not (VCS)
  • if those file are not shared (VCS-ed) we can regenerate those artifacs when the project is open (implement Project's Open Hook)
  • Override the javadoc-generate target to resolve the Javadoc problem
 (we need to ask the project owners to enable to hook up into javadoc-build target)
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo