-->

How can I create a netbeans 7.3 project wrapping t

2019-06-11 08:30发布

问题:

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:

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:

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:

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:

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.



回答2:

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.



回答3:

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)