Overlapping products in a common source tree

Layout on file system

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

  1. Click Opens the Java perspective Window > Open Perspective > Other... > Java to change to the Java perspective.

  2. Click Opens the New Java Project wizard File > New > Other... > Java Project to open the New Java Project wizard.

  3. Type "Product1" in the Project name field. Click Next.

    New Java Project wizard

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

    Click Link additional source link in Details pane or button Link Additional Source to Project in view bar.

    Java Project Source setup

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

    Type "src" in Folder name.

    Link Source dialog

  6. Click Finish to validate and close the dialog.

  7. Expand the "src" source folder. Select the three last packages and exclude them from build path using either Exclude from build path link or Exclude popup-menu item.

    Exclude packages from build path

  8. Your project source setup now looks as follows:

    Java Project Source final setup

  9. Click Finish.

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

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

    In Source tab, expand "Product2/src" source folder, select Excluded and click Edit....

    Java Build Path Properties Source tab

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

    Inclusion and Exclusion Patterns dialog

  12. Change "com/xyz/product2" to "com/xyz/product1".

    Edit Exclusion Pattern dialog

  13. Click OK to enter the change.

    Click Finish to validate and close Inclusion and Exclusion Patterns dialog.

    Click OK again to validate "Product2" project properties changes.

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

    Created Java projects in Workspace

Java projects
Java views New Java Project Wizard
Package Explorer View