何以解憂?唯有Java

          其實程序員也懂得浪漫!
          posts - 90, comments - 637, trackbacks - 0, articles - 2
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          What is freeform?  

          本博客使用了在線畫詞翻譯,大家對不懂的英文單詞可以用鼠標選中,然后就會看到翻譯了!
          Freeform is a NetBeans project type that allows you to use Ant build script supplied with your sources. Typical usecase can be that you have already some sources, you are developing them "in you own way" (other IDE, or using VI, or...) and you want to work on them using NetBeans. Other common usecase for free-form can be that you check out some opensource project and you want to work on it in NetBeans IDE.
          Let's take a look at some example. For a simple project, let's assume you have structure like this:
          • my_project
            • src
            • - contains Java sources
            • build
            • - this is where you build script puts *.class files
            • lib
            • - some JAR libraries you depend on
            • javadoc
            • - here is generated output from javadoc target in build.xml
            • tests
            • - tests for your sources
            • other
            • - misc stuff
            • >build.xml
            • - you own build script
          Of course this is just en example structure, and let's say ideal ;-). So if you want to set up this project as NetBeans project, you have to do something like this:
          1. Invoke New project wizard (File | New project | Java > Java Free-form project)
          2. Name and location panel
            • Location
            • - here you specify general location of your project. In this example you would browse for my_project folder
            • Build script
            • - if it's found under the project's folder, field gets populated automatically. Otherwise browse for your build.xml
            • Project name
            • - gets auto-populated from build.xml, feel free to change it if you wish
            • Project folder
            • - this is where your NetBeans project metadata will be stored. You will later open it in IDE using this project folder. It is possible to place it to other location than location of your project folder (my_project)
          3. Build and Run Actions panel
            • Here you just bind Ant targets to IDE actions. IDE tries to guess some of them. Modify as you wish.
          4. Source Packages Folders panel
            • Add here src folder as Source packages and tests as Test packages.
            • Hit Includes/Excludes button, it brings up dialog where you can setup what do you want to have in you source root visible. If you have e.g. HTML files mixed together with Java files in package folders, you may wish to exclude those HTML files, so that IDE's projects view won't display them.
          5. Java Sources panel
            • You need to set up project dependencies here. If you on know which JAR libraries your project depends, you can add them right now. Usually they are placed in lib folder, or similar, and are distributed together with project. Ideal case. If you have no idea, leave this empty, you can set up this later using Project properties dialog.
            • In the same way you set up dependencies for sources, set up also for tests.
          6. Project output panel
            • Here comes the tricky part. You need to bind here source folders you added on Source Packages Folders panel with binaries (JAR or folder with *.class files), that are produced from those sources. However, currently you don't have probably any, because you have only sources and you did not build anything. So for now invoke Finish, you'll get back to this later.
          7. Busting error badges
            • If you haven't set up all dependencies correctly, you see probably a lot of error badges on your project file. The only way how to get rid of them is to add libraries on Java source classpath (this is acessible from project properies). The correct way how to do this is to take a look into build.xml file to examine classpath. Another approach is to look at import statements in *.java files, and try to match them with content of lib folder (and add those matching JARs to Java source classpath). After a few iterations of adding library JAR files to Java source classpath should be red error badges gone.
          8. Binding project output
            • Invoke Build. If you set up target binding correctly, build action should be invoked on Ant script and should produce binaries. In our sample case are *.class files compiled under build folder. Go to project properties, and set build folder as output for your sourceroot. This is an important thing, if you are going to use debugging or you want some other project depend on your project.
            Now your project should be set up correctly. Note that this is not any generic manual how to set up every existing project as NetBeans free-form project. But it should get some insight of possible workflow during setting thing up for newbies :)

          評論

          # re: NetBeans中freeform project的作用(熟悉Ant 的朋友比較喜歡)  回復  更多評論   

          2009-11-13 21:35 by 董云武
          fgkdfpobif
          主站蜘蛛池模板: 普兰县| 汾阳市| 新宾| 平湖市| 玉环县| 隆德县| 正镶白旗| 台中县| 富阳市| 高要市| 万山特区| 安塞县| 平山县| 乌海市| 阳泉市| 永宁县| 磐安县| 德化县| 五大连池市| 桂东县| 庐江县| 绥棱县| 洱源县| 达州市| 永泰县| 耿马| 许昌市| 安国市| 左贡县| 灌云县| 仁怀市| 北辰区| 沈丘县| 镇原县| 道真| 柏乡县| 东海县| 茂名市| 都兰县| 元江| 静宁县|