Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

There is already a page that describes how to get started with Eclipse 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 we'll look at how to import the introducing-trips contributions and the jumpstart launcher that runs it from the Tuscany SCA Travel Sample.

These instructions assume that samples has been downloaded and unzipped and that the projects have already been compiled using Maven or Ant following the instructions in the sample's README. This is important because some of the source of in 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. The instructions were written using Eclipse 3.5.2.

Both of the approaches below import the sample modules into Eclipse without copying them. This means that any edits to the sample resources you see in Eclipse will result in changes in the directories where you unzipped the sample. You won't therefore 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 important as there are some cross references between the the various modules in the sample. If you copy the projects out of the sample structure they won't run properly without further editing.

1 - For the Maven user

1.1 - Creating Eclipse project files

...

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.

To import projects without using Without Maven we first 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.

...

Follow the steps detailing in the "Setup Eclipse for Tuscany" section of the page that discussed how to get started with Eclipse. 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.

2.3 - Create a Java project to contain the SCA

...

artifacts

Select File/New/Java Project to open the "Create a Java Project" dialog and the give the project a sensible name.
Image Added

Note that the "Create project from existing source" option is selected and the location of the introducing-trips project has been specified.

Now press the "Next >" button

2.4 - Import the SCA artifacts

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. Image Added
In this case you can just leave the defaults

2.5 - Specifying dependency projects

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.

2.6 - Specifying other dependencies

The Libraries tab allows you to specify the Tuscany jars that are required to compile this module. Image Added
We'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.

Once that's done you can press the Finish button at the bottom of the dialog. The result should be an introducing-trips project that compiles without error.

2.7 - Running the sample

To run the sample we 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 "Add External Jars..." button.

Once done you should have a jumpstart project that compiles without errors.

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.