Overlapping products in a common source tree

Layout on file system

Steps for defining corresponding "Product1" and "Product2" projects

  1. Open a Java perspective, select the menu item File > New > Project.... to open the New Project wizard.

  2. Select Java project in the list of wizards and click Next.

  3. On the next page, type "Product1" in the Project name field. Click Next.

    Layout 41

  4. On the next page, Select "Product1" source folder.

    Click Link Additional Source to Project button Link Additional Source to Project in view bar.

    Layout 42

  5. In Link Additional Source click Browse.... and choose the D:\AllJavaSourceFiles directory.

    Type "src" in Folder name.

    Layout 21

  6. Click OK to close the dialog.

  7. Click OK in confirmation dialog to have "Product1/bin" as default output folder.

    Layout 12

  8. Expand the "src" source folder. Select all packages you want to exclude and exclude them using popup-menu.

    Layout 22

  9. Your project source setup now looks as follows:

    Layout 23

  10. Click Finish.

  11. Copy "Product1" project and paste it as "Product2".

    Edit "Product2" project properties and go on Java Build Path page.

    Select Excluded and click Edit....

    Layout 24

  12. In Inclusion and Exclusion Patterns, select "com/xyz/product2" and click Edit....

    Layout 25

  13. Change "com/xyz/product2" to "com/xyz/product1" instead.

    Layout 26

  14. Click OK three times to valid and close all dialogs.

  15. You now have two Java projects which respectively contain the sources of "product1", "product2".

    Layout 27

Related concepts

Java projects
Java views

Related tasks

Working with build paths
Creating a new Java project
Creating a Java project with source folders
Creating a new source folder
Using the Package Explorer

Related reference

New Java Project Wizard
Package Explorer View