Space: Apache Tuscany (https://cwiki.apache.org/confluence/display/TUSCANY)
Page: Import existing Tuscany SCA projects into Eclipse 
(https://cwiki.apache.org/confluence/display/TUSCANY/Import+existing+Tuscany+SCA+projects+into+Eclipse)


Edited by Simon Laws:
---------------------------------------------------------------------
There is already a page that describes how to [get started with Eclipse|Getting 
Started with Tuscany] 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 well look at how to import the introducing-trips contributions and the 
jumpstart launcher that runs it from the [Tuscany SCA Travel Sample|SCA Java 
Travel Sample 1.x Releases]. These instructions assume that the projects have 
already been compiled using Maven or Ant. This is important because some of the 
source of the modules is generated during the compile stage and we need to 
import that into Eclipse along with the other source code and resources that 
the projects contain. 

h1. 1 - For the Maven user

h2. 1.1 - Creating Eclipse project files
Maven has a [plugin|http://maven.apache.org/guides/mini/guide-ide-eclipse.html] 
which will convert a Maven project into an Eclipse project. For example, to 
load the travel sample's introducing-trips contribution project into Eclipse 
first do the following:

{code}
cd travelsample/contributions/introducing-trips
mvn eclipse:eclipse
{code}

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 and Eclipse classpath variable called M2_REPO.  

h2. 1.2 - Setting the M2_REPO variable
Before loading the project in Eclipse we need to set M2_REPO as a classpath 
variable in our workspace to tell it where the Maven repository is. 

You can do this with maven using the following command. 

mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo

Alternatively you can do it manually as follows:

Open the Eclipse workspace you’re going to use then:

{code}
Select Window/Preferences
>From the resulting “Preferences” dialog select Java/Build Path/Classpath 
>Variables
Select the “New…” button
In the “Name:” field type M2_REPO
In the “Path:” field type <path to your maven repo>
{code}

h2. 1.3 - Loading an existing project into Eclipse

Once M2_REPO is set you can load the project into Eclipse

Open the Eclipse workspace you’re going to use then:

{code}
Select menu File/Import…
>From the resulting “Select” dialog box select General/Existing Projects into 
>Workspace
>From the resulting “Import Projects” dialog box select the “Browse…” button to 
>locate the travelsample/contributions/introducing-trips directory
Select “Finish”
{code}

The project should now appear in your workspace. 

h2. 1.4 - Running the sample

Now you have introducing-trips loaded you can repeat the process for the 
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 it 
will remain set. 

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. 

h1. 2 - For the non-Maven user

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. Without Maven we need to make all of the Tuscany libraries available to 
the SCA projects we load into Eclipse. We're going to do this by creating a 
TUSCANY library variable. Once we have this set we can create new projects, 
load existing resources into them and associate them with the TUSCANY variable 
so that all the dependencies are satisfied. 

h2. 2.1 - Install the Tuscany distribution 

Follow the steps detailing in the "Install the Tuscany distribution" section of 
the page that discussed how to [get started with Eclipse|Getting Started with 
Tuscany]. For the travel sample you'll need to install the latest 1.6 release 
of the Tuscany SCA Java runtime. 

h2. 2.2 - Setup Eclipse for Tuscany

Follow the steps detailing in the "Setup Eclipse for Tuscany" section of the 
page that discussed how to [get started with Eclipse|Getting Started with 
Tuscany]. For the travel sample you'll need to install the latest 1.6 release 
of the Tuscany SCA Java runtime. It's a this stage that the TUSCANY library 
variable gets set. 

h2. 2.3 - Create a Java project to contain the SCA artifact

h2. 2.4 - Import the SCA artifacts


Change your notification preferences: 
https://cwiki.apache.org/confluence/users/viewnotifications.action

Reply via email to