Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java Development User Guide
Previous Page Home Next Page

Project using a source framework with restricted access

Layout on file system

  • The Java source files for a product requires a source framework.
  • "Product" and "Framework" are in separate directories which have their own source and output folders.

    Layout on file system

Steps for defining corresponding 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 "Framework" in the Project name field.

  4. In Contents group, change selection to Create project from existing source.

    Click Browse... and choose the D:\Framework directory.

    New Java Project wizard

    Click Next.

  5. On the next page, verify that directory JavaSourceFiles has been automatically added as source folder.

    Expand it to preview your project source folder contents:

    Java Project Source setup

  6. Click Finish.
  7. In Java perspective, type Ctrl+N to open New wizards dialog.

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

  8. On the next page, type "Product" in the Project name field.

  9. In Contents group, change selection to Create project from existing source.

    Click Browse... and choose the D:\Product directory.

    New Java Project wizard

  10. Click Next.

  11. On the next page, verify that directory JavaSourceFiles has been automatically added as source folder.

    Expand it to preview your project source folder contents:

    Java Project Source setup

  12. Select Projects tab.

    Click Add...to add a dependency to source framework project...

    Java Project Required Projects setup

  13. In Required Project Selection, check "Framework".

    Required Project Selection dialog

  14. Click OK to validate and close dialog.

  15. Now, let's put access rules on source framework content to authorize, discourage or forbid access to "Framework" source folders, package and classes...

    In Projects tab, select "Access rules" of "Framework" depending project.

    Click Edit....

    Edit Required Project Access Rules

  16. In Type Access Rules, click Add....

    Type Access Rules dialog

  17. In Add Access Rule, select "Forbidden" for Resolution.

    Type "**/forbidden/**" in Rule Pattern field.

    Add Access Rule dialog

  18. Click OK to validate access rule and close dialog.

  19. Add another access rule:

    Resolution: "Discouraged" and Rule Pattern: "**/internal/**".

  20. Your access rules now look as follows:

    Type Access Rules final result

  21. Click OK to validate these new rules and close dialog.

  22. Dependent project has now 2 access rules set.

    Java Project Required Projects final setup

  23. Click Finish.

  24. You now have a Java project which contains the source of "Product" and which is using the source of "Framework".

    Some packages of the project "Framework" are restricted and if you try to import them, compiler displays either warnings or errors depending on your restriction level:

    Created Java projects in Workspace

Related concepts

Java projects

Related reference

New Java Project Wizard
Package Explorer View


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire