| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> |
| <html> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <title> |
| Project using a source framework with restricted access |
| </title> |
| <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script> |
| </head> |
| <body> |
| <h1> |
| Project using a source framework with restricted access |
| </h1> |
| <h3>Layout on file system</h3> |
| <ul> |
| <li>The Java source files for a product requires a source framework.</li> |
| <li>"Product" and "Framework" are in separate directories which have their own source and output folders.</li> |
| <p><img src="../images/qs-WorkingWithExistingLayout60.png" alt="Layout 60"></p> |
| </ul> |
| <h3>Steps for defining corresponding projects</h3> |
| <ol> |
| <li> |
| <p>Click |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.jdt.ui.JavaPerspective)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <strong>Window > Open Perspective > Other... > Java</strong></a> |
| to change to the Java perspective. |
| </p> |
| </li> |
| <li> |
| <p> |
| Click |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.newWizard(newWizardId=org.eclipse.jdt.ui.wizards.JavaProjectWizard)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <strong>File > New > Other... > Java Project</strong></a> |
| to open the <strong>New Java Project</strong> wizard. |
| </p> |
| </li> |
| <li> |
| <p>Type "Framework" in the <strong>Project name</strong> field.</p> |
| </li> |
| <li> |
| <p>In <strong>Contents</strong> group, change selection to <strong>Create project from existing source</strong>.</p> |
| <p>Click <strong>Browse...</strong> and choose the <i><code>D:\Framework</code></i> directory.</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout61.png" alt="Layout 61"></p> |
| <p>Click <strong>Next</strong>.</p> |
| </li> |
| <li> |
| <p>On the next page, verify that directory <i><code>JavaSourceFiles</code></i> has been automatically added as source folder.</p> |
| <p>Expand it to preview your project source folder contents:</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout62.png" alt="Layout 62"></p> |
| </li> |
| <li> |
| Click <strong>Finish</strong>. |
| </li> |
| <li> |
| <p>In Java perspective, type <strong>Ctrl+N</strong> to open <strong>New</strong> wizards dialog.</p> |
| <p>Select <strong>Java project</strong> in the list of wizards and click <strong>Next</strong>.</p> |
| </li> |
| <li> |
| <p>On the next page, type "Product" in the <strong>Project name</strong> field.</p> |
| </li> |
| <li> |
| <p>In <strong>Contents</strong> group, change selection to <strong>Create project from existing source</strong>.</p> |
| <p>Click <strong>Browse...</strong> and choose the <i><code>D:\Product</code></i> directory.</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout63.png" alt="Layout 63"></p> |
| <p>Click <strong>Next</strong>.</p> |
| </li> |
| <li> |
| <p>Let's add a dependency to source framework project...</p> |
| </li> |
| <li> |
| <p>On the next page, verify that directory <i><code>JavaSourceFiles</code></i> has been automatically added as source folder.</p> |
| <p>Select <strong>Projects</strong> tab.</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout64.png" alt="Layout 64"></p> |
| <p>Click <strong>Add...</strong>.</p> |
| </li> |
| <li> |
| <p>In <strong>Required Project Selection</strong>, check "Framework".</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout65.png" alt="Layout 65"></p> |
| <p>Click <strong>OK</strong>.</p> |
| </li> |
| <li> |
| <p>Now, let's put access rules on source framework content to authorize, discourage or forbid access to "Framework" source folders, package and classes...</p> |
| </li> |
| <li> |
| <p>In <strong>Projects</strong> tab, select "Access rules" of "Framework" depending project.</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout66.png" alt="Layout 66"></p> |
| <p>Click <strong>Edit...</strong>.</p> |
| </li> |
| <li> |
| <p>In <strong>Type Access Rules</strong>, click <strong>Add...</strong>.</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout67.png" alt="Layout 67"></p> |
| </li> |
| <li> |
| <p>In <strong>Edit Access Rule</strong>, select "Forbidden" for <strong>Resolution</strong>.</p> |
| <p>Type "**/forbidden/**" in <strong>Rule Pattern</strong> field.</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout68.png" alt="Layout 68"></p> |
| <p>Click <strong>OK</strong>.</p> |
| </li> |
| <li> |
| <p>Add another access rule:</p> |
| <p><strong>Resolution</strong>: "Discouraged" and <strong>Rule Pattern</strong>: "**/internal/**".</p> |
| </li> |
| <li> |
| <p>Your access rules now look as follows:</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout69.png" alt="Layout 69"></p> |
| <p>Click <strong>OK</strong>.</p> |
| </li> |
| <li> |
| <p>Dependent project has now 2 access rules set.</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout6a.png" alt="Layout 6a"></p> |
| <p>Click <strong>Finish</strong>.</p> |
| </li> |
| <li> |
| <p>You now have a Java project which contains the source of "Product" and which is using the source of "Framework".</p> |
| <p>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:</p> |
| <p><img src="../images/qs-WorkingWithExistingLayout6b.png" alt="Layout 6b"></p> |
| </li> |
| </ol> |
| |
| <p> |
| <img border="0" src="../images/ngrelc.png" alt="Related concepts" > |
| </p> |
| <p> |
| <a href="../concepts/concepts-3.htm">Java projects</a><br> |
| <a href="../tasks/tasks-6.htm">Java views</a><br> |
| </p> |
| <p> |
| <img src="../images/ngrelt.png" alt="Related tasks" border="0" > |
| </p> |
| <p> |
| <a href="../tasks/tasks-110.htm">Working with build paths</a><br> |
| <a href="../tasks/tasks-12.htm">Creating a new Java project</a><br> |
| <a href="../tasks/tasks-14.htm">Creating a Java project with source folders</a><br> |
| <a href="../tasks/tasks-26.htm">Creating a new source folder</a><br> |
| <a href="../tasks/tasks-45.htm">Using the Package Explorer</a><br> |
| </p> |
| <p> |
| <img src="../images/ngrelr.png" alt="Related reference"> |
| </p> |
| <p> |
| <a href="../reference/ref-121.htm">New Java Project Wizard</a><br> |
| <a href="../reference/ref-view-package-explorer.htm">Package Explorer View</a><br> |
| </p> |
| |
| </body> |
| </html> |
| |