blob: e029297a3b49425b59c62302bb1551950823c794 [file]
<!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>&quot;Product&quot; and &quot;Framework&quot; are in separate directories which have their own source and output folders.
<p><img src="images/qs-WorkingWithExistingLayout60.png" alt="Layout on file system"></p></li>
</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" alt="Opens the Java perspective">
<strong>Window &gt; Open Perspective &gt; Other... &gt; 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" alt="Opens the New Java Project wizard">
<strong>File &gt; New &gt; Other... &gt; Java Project</strong></a>
to open the <strong>New Java Project</strong> wizard.
</p>
</li>
<li>
<p>Type &quot;Framework&quot; 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="New Java Project wizard"></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="Java Project Source setup"></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 &quot;Product&quot; 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="New Java Project wizard"></p>
</li>
<li>
<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-WorkingWithExistingLayout64.png" alt="Java Project Source setup"></p>
</li>
<li>
<p>Select <strong>Projects</strong> tab.</p>
<p>Click <strong>Add...</strong>to add a dependency to source framework project...</p>
<p><img src="images/qs-WorkingWithExistingLayout65.png" alt="Java Project Required Projects setup"></p>
</li>
<li>
<p>In <strong>Required Project Selection</strong>, check &quot;Framework&quot;.</p>
<p><img src="images/qs-WorkingWithExistingLayout66.png" alt="Required Project Selection dialog"></p>
</li>
<li>
<p>Click <strong>OK</strong> to validate and close dialog.</p>
</li>
<li>
<p>Now, let's put access rules on source framework content to authorize, discourage or forbid access to &quot;Framework&quot; source folders, package and classes...</p>
<p>In <strong>Projects</strong> tab, select &quot;Access rules&quot; of &quot;Framework&quot; depending project.</p>
<p>Click <strong>Edit...</strong>.</p>
<p><img src="images/qs-WorkingWithExistingLayout67.png" alt="Edit Required Project Access Rules"></p>
</li>
<li>
<p>In <strong>Type Access Rules</strong>, click <strong>Add...</strong>.</p>
<p><img src="images/qs-WorkingWithExistingLayout68.png" alt="Type Access Rules dialog"></p>
</li>
<li>
<p>In <strong>Add Access Rule</strong>, select &quot;Forbidden&quot; for <strong>Resolution</strong>.</p>
<p>Type &quot;**/forbidden/**&quot; in <strong>Rule Pattern</strong> field.</p>
<p><img src="images/qs-WorkingWithExistingLayout69.png" alt="Add Access Rule dialog"></p>
</li>
<li>
<p>Click <strong>OK</strong> to validate access rule and close dialog.</p>
</li>
<li>
<p>Add another access rule:</p>
<p><strong>Resolution</strong>: &quot;Discouraged&quot; and <strong>Rule Pattern</strong>: &quot;**/internal/**&quot;.</p>
</li>
<li>
<p>Your access rules now look as follows:</p>
<p><img src="images/qs-WorkingWithExistingLayout6a.png" alt="Type Access Rules final result"></p>
</li>
<li>
<p>Click <strong>OK</strong> to validate these new rules and close dialog.</p>
</li>
<li>
<p>Dependent project has now 2 access rules set.</p>
<p><img src="images/qs-WorkingWithExistingLayout6b.png" alt="Java Project Required Projects final setup"></p>
</li>
<li>
<p>Click <strong>Finish</strong>.</p>
</li>
<li>
<p>You now have a Java project which contains the source of &quot;Product&quot; and which is using the source of &quot;Framework&quot;.</p>
<p>Some packages of the project &quot;Framework&quot; 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-WorkingWithExistingLayout6c.png" alt="Created Java projects in Workspace"></p>
</li>
</ol>
<P class="nav_footer" id="nav_footer">Next Section: <A href="qs-with-j2se50.htm">Eclipse and J2SE 5.0</A>
</P>
<p>
<img border="0" src="../images/ngrelc.png" alt="Related concepts" >
</p>
<p>
<a href="../concepts/concepts-3.htm">Java projects</a>
</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>