0

I thought this is an easy question because there's already a wiki topic about this here especially this section. however the wiki is out of date. A prior question exists here on Stackoverflow that only has a reference to these now out of date wiki topics. The netbeans wiki must be for some older version of NetBeans UI, and I'm using NetBeans 7.3.

If I try to use the existing sources option in 7.3 it assumes that you cannot have a build.xml already, and so it tells you you cannot proceed:

enter image description here

For illustration purposes it may help to show some structure of jedit source code folders. I have both the latest jEdit source code and the 5.0 stable source code. The project layout is roughly like this:

      + jedit
        |
        +- org
        |
        +- net
        |
        +- test
        |
        +- de
        |
        ....

I have located the folder where the root build.xml is located, but I cannot follow the wiki instructions because there does not appear to be such a project-with-existing-ant-build-script option anymore.

And Now We Try the Free-Form option... and it doesn't work either...

The free-form project works in so far is that it lets you create a netbeans project, but the scan of the directory results in a complete mess inside netbeans. A series of folders with path "." are added, 5 copies of a duplicate "." folder, and 5 duplicate "Source Packages" entries in the project tree view. This may be related to the second problem with free-form which is that it will not build and run jEdit, but dies with a strange error message that does not happen when I try to build outside netbeans:

The mess in the project pane, leaves me unable to navigate or see the source structure:

enter image description here

And it doesn't build:

Processing /Users/admin/NetBeansProjects/jedit/trunk/build/test/merged-reports/TESTS-TestSuites.xml to /var/folders/59/mc8gzxfn1b98j389rkz4zjsc0000gs/T/null666107982
Loading stylesheet jar:file:/Applications/NetBeans/NetBeans%207.3.app/Contents/Resources/NetBeans/java/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
: Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
: Error! Cannot convert data-type 'void' to 'reference'.
: Fatal Error! Could not compile stylesheet
Failed to process /Users/admin/NetBeansProjects/jedit/trunk/build/test/merged-reports/TESTS-TestSuites.xml
/Users/admin/NetBeansProjects/jedit/trunk/build.xml:442: Errors while applying transformations: Fatal error during transformation
BUILD FAILED (total time: 35 seconds)

So I gave up on the free-form project because it doesn't build.

And now on to opening a project with existing sources after removing the build folder and build.xml which doesn't work either...

If I want to import project sourcecode (just the java, no build.xml because I deleted it), I get stuck here:

enter image description here

What did I try to do? I tried to add the source folders, as directories under org, de and net (see the source tree I put above in my question). However netbeans automatically traverses upwards to the ROOT folder of my source code.

I am unable to select any folder OTHER than the root because selecting a folder underneath it leads to Netbeans unhelpfully always moving back up the folder hierarchy until it arrives where it wants to be. It won't be told any different.

This in turn leads to netbeans complaining about something it decided to do to me, which is that it can't include jedit/test because it's using jedit as the root source folder. Nothing I select (however many folders below jedit/) results in netbeans doing anything differently. It insists on traversing back through subdirectories in an effort to be helpful. I am beginning to think that the real world users of java may organize their source code in a way that netbeans cannot handle.

Other Information

  • Building from the shell with ant against the default build.xml shipping with the sources of jedit works fine, as long as you have a modern version of ant. Reinstalling ant fixed my command line build abilities.

  • I found that I had to install the latest ant version from the apache website before my Mac OS X box would build jEdit 5.0 at the command line. The ant version inside my netbeans app bundle may be different.

  • I am using OS X 10.8 and hava Java 1.5, 1.6, and 1.7 installed, currently building against java 1.6.

  • It seems to me that Netbeans opens Maven projects with aplomb and grace and this in turn is due to Maven projects generally following standard java directory layouts. Ant-based builds also seem to import nicely to the extent that naming and layout standards are intelligible to Netbeans, but jEdit appears to be something that Netbeans can't cleanly handle in its current form.

1

3 Answers 3

2

The URL below has instructions to setup and compile jEdit 5.0.0 source in NetBeans 7.3.

http://www.areaofthoughts.com/2013/01/compiling-running-jedit-5-in-netbeans-73.html

Summary:

  • jsr305-2.0.1.jar dependency must be downloaded and added manually to netbeans Libraries tab or else javax.annotation.Nonnull and javax.annotation.Nullable will not resolve.

  • Unpacking the jedit source code to a subdirectory 1 level underneath the folder that will be the netbeans project is essential.

5
  • Is it an regression in netbeans 7.3 that you can't advance to the "next" step without selecting a Test folder, something which is current impossible and means that the steps in this article don't work for me.
    – Warren P
    Mar 30, 2013 at 3:53
  • Did you try my steps? From the screenshots above you are trying to put the jEdit project directories in the upper level project directory and you can't do that. NetBeans won't complain if you set the directory structure up right. Have you tried my steps exactly in the URL? I set it up just like I described and it works. The screenshot you show is giving an error because you do not have the directory structure right, it has nothing to do with a test directory. I don't understand why it is showing a test directory in the screenshot, did you add it?
    – MackSix
    Mar 30, 2013 at 4:34
  • I messed up by assuming that the test folder was required. I used a folder named source the second time through and the level above it I called jedit and that made more sense to my poor head, but otherwise, I followed what you did exactly and it worked great. This was educational in that it showed me how incredibly powerful the Netbeans IDE project configuration is. I am so impressed.
    – Warren P
    Mar 30, 2013 at 18:40
  • I am glad it worked. Out of curiosity I tried the freeform project and there is a bug that creates the multiple source package directories in the NetBeans project.xml and it shows like in your screenshot above. It only occurs with jEdit project for me and not on a test project. Also, it only happens when content folder and project folder are different. The build still fails in NetBeans anyway due to what appears to be an Ant bug that rears it's ugly head in NetBeans and Eclipse. netbeans.org/bugzilla/show_bug.cgi?id=201022 and bugs.eclipse.org/bugs/show_bug.cgi?id=384757
    – MackSix
    Mar 31, 2013 at 9:09
  • I edited your answer so that the two most pertinent technical facts are located here, lest your blog go away in 6 months time, that's standard operating procedure for StackOverflow.
    – Warren P
    Apr 1, 2013 at 15:41
1

The screen shot states that /Users/admin/NetBeansProject/jedit/trunk already contains a build.xml file. You should try creating a "Freeform Project" in NetBeans instead of a "New Java Project with Existing Sources".

If you don't want to reuse the existing build.xml file, you can copy your source files to a new directory. In particular, you should place them in the src subdirectory of an otherwise empty directory for the NetBeans project. Then you can create a "New Java Project with Existing Sources." You shouldn't need to create your own Ant build file unless you need to add custom tasks or customize the default ones which are generated by NetBeans.

6
  • With freeform projects, the jEdit program does not build but dies with the error above. If I copy the source files to a new directory then I will have to build a project from scratch folder by folder. I am not sure I can do that. I know that the com, org and de folders contain sources, but not sure if that's enough.
    – Warren P
    Mar 29, 2013 at 1:08
  • @WarrenP Try specifying the build file as "build.xml" rather than "build-nb.xml". Mar 29, 2013 at 1:10
  • @WarrenP If that doesn't work, ping me and I'll download the JEdit sources and see what I can figure out with them. Mar 29, 2013 at 1:14
  • @WarrenP Feel free to post a new question about those issues. When I have some time tomorrow I'll download JEdit and see what I can do on a Windows and/or Linux box. Mar 29, 2013 at 1:52
  • I decided to edit my question to make it better. I believe this is a matter of (a) me being relatively inexperienced in java and (b) netbeans making all sorts of assumptions about java source code folder organization and build structure that doesn't match common existing open source java projects like jedit's long-time practices. Am I right?
    – Warren P
    Mar 29, 2013 at 13:23
0

I can't comment on using Netbeans for Java, as I code PHP with it only. But when loading a project with existing PHP sources, I can save my project configuration file in the project or at another location (and I do sometimes save the project config to my windows profile, as the sources are on a samba share on my linux web server)

3
  • Uh I am not sure what you're saying exactly or how it answers this question.
    – Warren P
    Mar 28, 2013 at 23:28
  • I don't believe this does answer your question, I just hoped it lead you in a positive direction.
    – DragonZero
    Mar 28, 2013 at 23:37
  • I believe my issue is "how do I create a proper ant xml file that wraps the build process already in place and used by jedit, that will also look enough like a regular netbeans project to make netbeans a viable way of reading and learning jedit's source code". A PHP user of NetBeans would not probably know ANT .xml or jedit, so thanks anyways.
    – Warren P
    Mar 28, 2013 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.