Structuring Project Dependencies


Unlike other NetBeans project types, Mobility projects are based on the concept of a single source root that results in a single distribution JAR file. It is possible to simulate multiple source roots by setting up one project for each source root and then using project dependencies. It may be helpful to think of the source root containing the MIDlet as the application project, while all other source roots should be considered library projects.

There are no programmatic differences between Library and Application projects other than the option to include a MIDlet when creating an Application project. The differences between project types are purely conceptual in nature.


To structure your project dependencies:

  1. Right-click your application project in the Projects window and choose Properties.

  2. Select the Libraries & Resources panel in the Project Properties dialog box.

  3. Click Add Project.

  4. Navigate to the project root of a Library project and ensure that the correct Project JAR file is selected in the Select Project JAR Files dialog box.

  5. Click Add Selected Project JAR Files.

  6. Repeat for each Library project.

    If there are interdependencies among the Library projects, these must be set up in the same manner. Note that dependencies may not be circular; if project A depends on project B, project B cannot depend on project A (or any other project that depends on project A).

Using Dependencies with Configurations

If your Library project and Application project make use of project configurations, it is important to take care when setting up the project dependencies. Although it is tempting to assume that the Application project will automatically depend on the correct version of the Library project (based on configuration name matching), this is not the case.

Assume, for example, you are working with an Application project that has configurations named SmallScreen and LargeScreen, and a Library project that has two configurations of the same name. To set up the dependency between the two projects:

  1. Right-click your Application project in the Projects window and choose Properties.

  2. Select the Libraries & Resources panel in the Project Properties dialog box.

  3. Select the SmallScreen configuration from the Project Configuration combo box and then uncheck the Use Values from "DefaultConfiguration" checkbox.

  4. Click Add Project.

  5. Navigate to the project root of the Library project and Select the project JAR file that is prefaced with /dist/SmallScreen in the Select Project JAR Files dialog box.

  6. Click Add Selected Project JAR Files.

  7. Select the LargeScreen configuration from the Project Configuration combo box and then repeat these steps (but selecting the /dist/LargeScreen distribution JAR file when appropriate).

  8. Click OK.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net