summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/import-existing-tuscany-sca-projects-into-eclipse.html
diff options
context:
space:
mode:
Diffstat (limited to 'site/trunk/site-publish/import-existing-tuscany-sca-projects-into-eclipse.html')
-rw-r--r--site/trunk/site-publish/import-existing-tuscany-sca-projects-into-eclipse.html293
1 files changed, 293 insertions, 0 deletions
diff --git a/site/trunk/site-publish/import-existing-tuscany-sca-projects-into-eclipse.html b/site/trunk/site-publish/import-existing-tuscany-sca-projects-into-eclipse.html
new file mode 100644
index 0000000000..0aee9df74d
--- /dev/null
+++ b/site/trunk/site-publish/import-existing-tuscany-sca-projects-into-eclipse.html
@@ -0,0 +1,293 @@
+
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE- 2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<HTML>
+ <HEAD>
+ <!-- generateKeywords macro -->
+ <META name="description" content="Apache Tuscany">
+ <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture, sca, service component architecture, das, sdo, csa, ruby, opensource">
+ <!-- generateKeywords macro end -->
+
+ <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
+ <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">
+ <TITLE>Apache Tuscany : Import existing Tuscany SCA projects into Eclipse</TITLE>
+ <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
+
+ <BODY onload="init()">
+ <!-- topNav macro -->
+ <TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
+ <TR>
+ <TD valing="top" align="left">
+ <A href="https://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
+ </TD>
+ <TD>
+ <A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
+ </TD>
+
+ <TD width="100%">
+ &nbsp;
+ </TD>
+
+ <!-- Adds the edit page link to the top banner-->
+ <TD valign="bottom">
+ <DIV style="padding: 2px 10px; margin: 0px;">
+ <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=23337381">
+ <IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
+ </DIV>
+ </TD>
+
+ </TR>
+ </TABLE>
+ <!-- topNav macro end -->
+
+ <!-- breadCrumbs macro -->
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR class="topBar">
+ <TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
+ &nbsp;<A href="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="sca-overview.html" title="SCA Overview">SCA Overview</A>&nbsp;&gt;&nbsp;<A href="sca-java.html" title="SCA Java">SCA Java</A>&nbsp;&gt;&nbsp;<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="" title="Import existing Tuscany SCA projects into Eclipse">Import existing Tuscany SCA projects into Eclipse</A>
+ </TD>
+
+ <TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
+ <A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
+ </TD>
+ </TR>
+ </TABLE>
+ <!-- breadCrumbs macro end -->
+
+
+ <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
+ <TR>
+ <TD align="left" valign="top">
+
+ <!-- pageContent macro -->
+ <DIV id="PageContent">
+
+ <DIV class="pagecontent">
+ <DIV class="wiki-content">
+ <P>There is already a page that describes how to <A href="getting-started-with-tuscany.html" title="Getting Started with Tuscany">get started with Eclipse</A> by building a new Tuscany SCA project from scratch. How do you though use the various existing samples and examples that are provided with Tuscany from within Eclipse? Here we'll provide some instructions about how to do just that for both the Maven user and the non-Maven user. As an example we'll look specifically at how to import the introducing-trips contributions and the jumpstart launcher that runs it from the <A href="sca-java-travel-sample-1x-releases.html" title="SCA Java Travel Sample 1.x Releases">Tuscany SCA Travel Sample</A>. We'll also explain how to use the same approach to import other samples such as the samples in the Tuscany SCA Java binary distribution and the complete travel sample code.</P>
+
+<P>These instructions assume that the sample code being loaded into Eclipse has been downloaded and unzipped and the sample modules have already been compiled using Maven or Ant following the instructions in the sample's README. This is important because some of the source in sample modules is generated during the compile stage and you'll need to import that into Eclipse along with the other source code and resources that the sample modules contain. These instructions were written using Eclipse 3.5.2.</P>
+
+<P>Both of the approaches described below import the sample modules into Eclipse without copying them. This means that any edits to the sample resources that you make in Eclipse will result in changes in the directories where you unzipped the sample, and you won't see copies of these projects appear in the Eclipse workspace directory on disc. This is generally a useful approach as it lets you work directly on projects outside of the Eclipse workspace. In the case of the travel sample it's particularly important because there are some cross references between the various modules in the sample. If you copy the projects out of the sample structure they won't run properly without further editing.</P>
+
+
+<H1><A name="ImportexistingTuscanySCAprojectsintoEclipse-1FortheMavenuser"></A>1 - For the Maven user</H1>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-1.1CreatingEclipseprojectfiles"></A>1.1 - Creating Eclipse project files</H2>
+
+<P>Maven has a <A href="http://maven.apache.org/guides/mini/guide-ide-eclipse.html" class="external-link" rel="nofollow">plugin</A> which will convert a Maven project into an Eclipse project. For example, to load the travel sample's introducing-trips contribution into Eclipse as a project first do the following:</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+cd travelsample/contributions/introducing-trips
+mvn eclipse:eclipse
+</PRE>
+</DIV></DIV>
+
+<P>That generates, amongst other things, .classpath and .project files into the introducing-trips directory. These files effectively make the introducing-trips module an Eclipse project that can be loaded directly into Eclipse. This Eclipse project will reference dependencies in the local Maven repository, based on the contents of the pom.xml file. These dependency references are constructed using an Eclipse classpath variable called M2_REPO.</P>
+
+<P>The previous example shows how to run a <TT>mvn</TT> command to create a single Eclipse project. It's often useful to run a single <TT>mvn</TT> command from a top-level directory to create multiple Eclipse projects. For example, to create Eclipse projects for all the samples in the Tuscany SCA Java 1.6.1 (or later 1.x) binary distribution, you can do the following:</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+cd samples
+mvn eclipse:eclipse
+</PRE>
+</DIV></DIV>
+
+<P>This runs the <TT>mvn eclipse:eclipse</TT> command for all the samples under the top-level <TT>samples</TT> directory. As well as being more convenient than running a <TT>mvn eclipse:eclipse</TT> command for each sample, using a single <TT>mvn eclipse:eclipse</TT> command from a top-level directory enables the Maven plugin to discover any dependency relationships between the samples and create corresponding dependency relationships between the generated Eclipse projects. You can do this for the complete travel sample by doing the following:</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+cd travelsample
+mvn eclipse:eclipse
+</PRE>
+</DIV></DIV>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-1.2SettingtheM2REPOvariable"></A>1.2 - Setting the M2_REPO variable</H2>
+
+<P>Before loading the project into Eclipse you need to set M2_REPO as a classpath variable in your workspace to tell it where the Maven repository is.</P>
+
+<P>You can do this with Maven using the following command.</P>
+
+<P><TT>mvn &#45;Declipse.workspace=&lt;path-to-eclipse-workspace&gt; eclipse:add-maven-repo</TT></P>
+
+<P>Alternatively you can do it manually by opening the Eclipse workspace you&rsquo;re going to use and then:</P>
+
+<P>Select Window/Preferences<BR class="atl-forced-newline">
+From the resulting &ldquo;Preferences&rdquo; dialog select Java/Build Path/Classpath Variables<BR class="atl-forced-newline">
+Select the &ldquo;New&hellip;&rdquo; button<BR class="atl-forced-newline">
+In the &ldquo;Name:&rdquo; field type M2_REPO<BR class="atl-forced-newline">
+In the &ldquo;Path:&rdquo; field type &lt;path to your maven repo&gt;</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-1.3LoadinganexistingprojectintoEclipse"></A>1.3 - Loading an existing project into Eclipse</H2>
+
+<P>Once M2_REPO is set you can load the project(s) into Eclipse by opening the Eclipse workspace you&rsquo;re going to use and then:</P>
+
+<P>Select menu File/Import&hellip;<BR class="atl-forced-newline">
+From the resulting &ldquo;Select&rdquo; dialog box select General/Existing Projects into Workspace<BR class="atl-forced-newline">
+From the resulting &ldquo;Import Projects&rdquo; dialog box select the &ldquo;Browse&hellip;&rdquo; button to locate the directory containing the project(s) to import<BR class="atl-forced-newline">
+Select &ldquo;Finish&rdquo;</P>
+
+<P>For example, to load the contributions/introducing-trips project from the travel sample, you would select the <TT>travelsample/contributions/introducing-trips</TT> directory. To load all the Tuscany binary distribution samples you would select the <TT>samples</TT> directory, and to load the complete travel sample you would select the <TT>travelsample</TT> directory.</P>
+
+<P>The project should now appear in your workspace.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-1.4Runningthesample"></A>1.4 - Running the sample</H2>
+
+<P>Now you have introducing-trips loaded you can repeat the process for the travel sample launchers/jumpstart module. Repeat step 1.1 for launchers/jumpstart and then load it into Eclipse with step 1.3. You don't need to repeat step 1.2 as M2_REPO will remain set.</P>
+
+<P>Now open up the scatours-launcher-jumpstart project in Eclipse (the project name comes from the Maven module name specified in the pom.xml file) and look for the JumpstartLauncher.java file. If you right click on that file and select Run As Application the sample should run. Alternatively you can select Debug As Application if you want to set debugging breakpoints.</P>
+
+<P>You can run other samples by finding the main class and selecting Run As Application.</P>
+
+<H1><A name="ImportexistingTuscanySCAprojectsintoEclipse-2ForthenonMavenuser"></A>2 - For the non-Maven user</H1>
+
+<P>Maven gives a fair bit of help in creating Eclipse projects from existing project. Most of the effort is involved in working out what the dependencies are.</P>
+
+<P>To import projects without using Maven you first need to make all of the Tuscany libraries available to the SCA projects you'll be loading into Eclipse. You can do this by creating a TUSCANY library variable. Once you have this set you can create new projects, load existing resources into them and associate them with the TUSCANY variable so that all the dependencies are satisfied.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.1InstalltheTuscanydistribution"></A>2.1 - Install the Tuscany distribution</H2>
+
+<P>Follow the steps detailing in the &quot;Install the Tuscany distribution&quot; section of the page that discussed how to <A href="getting-started-with-tuscany.html" title="Getting Started with Tuscany">get started with Eclipse</A>. For the travel sample you'll need to install the 1.6 (or later 1.x) release of the Tuscany SCA Java runtime.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.2SetupEclipseforTuscany"></A>2.2 - Setup Eclipse for Tuscany</H2>
+
+<P>Follow the steps detailing in the &quot;Setup Eclipse for Tuscany&quot; section of the page that discussed how to <A href="getting-started-with-tuscany.html" title="Getting Started with Tuscany">get started with Eclipse</A>. For the travel sample you'll need to install the 1.6 (or later 1.x) release of the Tuscany SCA Java runtime. It's at this stage that the TUSCANY library variable gets set.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.3CreateaJavaprojecttocontaintheSCAartifacts"></A>2.3 - Create a Java project to contain the SCA artifacts</H2>
+
+<P>Select File/New/Java Project to open the &quot;Create a Java Project&quot; dialog and the give the project a sensible name.<BR>
+<SPAN class="image-wrap" style=""><IMG src="import-existing-tuscany-sca-projects-into-eclipse.data/create-java-project2.png" style="border: 1px solid black"></SPAN></P>
+
+<P>Note that the &quot;Create project from existing source&quot; option is selected and the location of the introducing-trips project has been specified.</P>
+
+<P>Now press the &quot;Next &gt;&quot; button</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.4ImporttheSCAartifacts"></A>2.4 - Import the SCA artifacts</H2>
+
+<P>The next panel allows you to set up the structure of the new project. The source tab allows you to determine where the source code and other resources can be found. <SPAN class="image-wrap" style=""><IMG src="import-existing-tuscany-sca-projects-into-eclipse.data/create-java-project-sources.png" style="border: 1px solid black"></SPAN><BR>
+In this case you can just leave the defaults. You'll need to configure the introducing-trips/src/main/resources folder as a source folder for the project but it's easier to do this once the project has been created.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.5Specifyingdependencyprojects"></A>2.5 - Specifying dependency projects</H2>
+
+<P>The Projects tab allows you to specify which other projects this project depends on. Some of the travel sample modules rely on other other modules, for example, the contributions/common module. However this is not the case here so you can just leave this tab with the default setting.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.6Specifyingotherdependencies"></A>2.6 - Specifying other dependencies</H2>
+
+<P>The Libraries tab allows you to specify the Tuscany jars that are required to compile this module.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="import-existing-tuscany-sca-projects-into-eclipse.data/create-java-project-libs.png" style="border: 1px solid black"></SPAN></P>
+
+<P>You've already configured the TUSCANY library in step 2.2 so you can select this using the Add Library button an selecting User Library in the resulting dialog.</P>
+
+<P>Once that's done you can press the Finish button at the bottom of the dialog. The result should be an introducing-trips project.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.7Addingextrasourcefolders"></A>2.7 - Adding extra source folders</H2>
+
+<P>Eclipse doesn't automatically pick up some of the folders that have been configured in the Maven modules. These are usually:</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+src/main/resources
+src/test/resources
+target/jaxws-source
+</PRE>
+</DIV></DIV>
+
+<P>You need to configure these manually as source directories. Right click on the project and select &quot;Properties&quot; options. </P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="import-existing-tuscany-sca-projects-into-eclipse.data/project-properties.png" style="border: 1px solid black"></SPAN></P>
+
+<P>Now press the &quot;Add Folder&quot; button and select the project folder that you want to include as a source folder, in this case src/main/resources. Press OK to return.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-2.8Runningthesample"></A>2.8 - Running the sample</H2>
+
+<P>To run the sample you need to import launchers/jumpstart by repeating steps 2.3, 2.4, 2.5, 2.6 and 2.7 for the jumpstart project. There is extra work required at step 2.6 this time though. The jumpstart module has unit tests that depend on the junit-4.5.jar that ships in the tuscany-scatours-1.0\lib\junit directory. Add this as a dependency of the project using the &quot;Add External Jars...&quot; button.</P>
+
+<P>Once done you should have a jumpstart project that compiles without errors.</P>
+
+<P>Now open up the scatours-launcher-jumpstart project in Eclipse (the project name comes from the Maven module name specified in the pom.xml file) and look for the JumpstartLauncher.java file. If you right click on that file and select Run As Application the sample should run.</P>
+
+<H1><A name="ImportexistingTuscanySCAprojectsintoEclipse-3UsingtheMavenpluginforEclipse"></A>3 - Using the Maven plugin for Eclipse</H1>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-3.1Installthem2eclipsepluginintoEclipse"></A>3.1 - Install the m2eclipse plugin into Eclipse</H2>
+
+<P><A href="http://m2eclipse.sonatype.org/" class="external-link" rel="nofollow">m2eclipse</A> offers integration of Maven with the Eclipse platform. It provides two plugins which give you different levels of integration:</P>
+
+<UL>
+ <LI>m2eclipse Core - will be installing of the core Wizards, the POM Editor, Maven Repository integration, and Maven integration.</LI>
+ <LI>m2eclipse Extras - will be installing more features like Maven SCM integration, Eclipse Web Tools Platform integration and others.</LI>
+</UL>
+
+
+<P>In order to install the plugins, open Eclipse and go to Help -&gt; <B>Install New Software...</B>. In the newly opened window click <B>Add...</B> from the <B>Work with</B> area and enter the following update sites:</P>
+
+<UL>
+ <LI><A href="http://m2eclipse.sonatype.org/sites/m2e" class="external-link" rel="nofollow">http://m2eclipse.sonatype.org/sites/m2e</A> for m2eclipse core</LI>
+ <LI><A href="http://m2eclipse.sonatype.org/sites/m2e-extras" class="external-link" rel="nofollow">http://m2eclipse.sonatype.org/sites/m2e-extras</A> for m2eclipse extras</LI>
+</UL>
+
+
+<P>Continue installation by selecting which modules to install and accepting terms of agreement.</P>
+
+<P>m2eclipse uses an embedded installation of Maven by default. This can be changed with a specific instance of Maven found on the disk by entering the <B>Windows -&gt; Preferences</B> menu in Eclipse. Click the <B>Maven</B> section and all the Maven integration related options will be displayed. In the <B>Installations</B> category, changes can be performed regarding the Maven instance and configuration file to use.</P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-3.2ImporttheSCAartifacts"></A>3.2 - Import the SCA artifacts</H2>
+
+<P>Go to <B>File -&gt; Import...</B> in the Eclipse menu. From the <B>Maven</B> category, choose <B>Existing Maven Projects</B> and click <B>Next</B>. In the next step, choose a root directory and the plugin will show you all the Maven projects inside it and it's subdirectories. Choose one of them and click <B>Next</B>. From here on, m2eclipse will take care of resolving the dependencies, generating the Eclipse specific files. </P>
+
+<P>Notice the project icon containing an <B>M</B> in the top left corner indicating the Maven nature of the project. To disable the Maven nature of a project, right click on the project, go to the <B>Maven</B> context menu and click <B>Disable Dependency Management</B>. </P>
+
+<H2><A name="ImportexistingTuscanySCAprojectsintoEclipse-3.3RunningSCAcontributionsandwebapps"></A>3.3 - Running SCA contributions and webapps</H2>
+
+<P>Once imported, Maven projects can be run in Eclipse using the well-known context menu <B>Run As</B> and choosing the appropriate category. </P>
+
+<P>Also, Maven related tasks (goals like compile, test, package, install, etc.) can be run by using the project context menu and going to the <B>Maven</B> sub-menu. </P>
+
+<P>Web applications can also be run from inside the <B>Servers</B> view as the m2eclipse extras plugin provides integration with Eclipse WTP. This enables Eclipse to recognize web applications managed by Maven. To add an application to a server, right click the server in the <B>Servers</B> view and go to <B>Add and Remove...</B>. Select which apps to publish to a particular server. Managing server state (starting, stopping, restarting, starting in debug mode) can be done using the provided buttons in the <B>Servers</B> view. Source code or resource changes are automatically synchronized with the published version on the server. The view also indicates if the application server needs to be restarted in order to apply major changes.</P>
+ </DIV>
+ </DIV>
+ </DIV>
+ <!-- pageContent macro end -->
+
+ </TD>
+ </TR>
+ </TABLE>
+
+ <!-- footer macro -->
+ <SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </SCRIPT>
+ <SCRIPT type="text/javascript">
+ _uacct = "UA-1174707-5";
+ urchinTracker();
+ </SCRIPT>
+
+ <A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>
+
+ <DIV class="footer">
+ Copyright � 2003-2012, The Apache Software Foundation&nbsp;&nbsp;</BR>
+ Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
+ </DIV>
+ <!-- footer macro end -->
+
+ </BODY>
+</HTML>