This quick guide will take you through the steps necessary to create Spring Dynamic Modules development environment using Eclipse IDE Check out the Spring-DM project
Create directory where you want to check the project out and navigate to it. > mkdir spring-dm-dev > cd spring-dm-dev
Check out the project: > svn co https://springframework.svn.sourceforge.net/svnroot/springframework/spring-osgi/trunk spring-osgi This will check out the Spring Dynamic Modules project into spring-osgi directory Build projectNavigate to the directory where you checked out the project >cd spring-osgi/ Build the project using Eclipse Equinox profile. The other available profiles are knoplerfish and felix. For more information on profiles refer to Maven documentation. >mvn -P equinox clean install Make sure build is successfull. Configure Eclipse
Start Eclipse and create a new workspace (you can use existing one if you want, but the new one will avoid potential issue carried over from the existing workspace) mvn eclipse:configure-workspace -Declipse.workspace=/Users/kermit/Dev/eclipse/workspaces/Spring-DM-setup Restart Eclipse to pick up a new configuration Import projects into Eclipse
Ironically, Spring Dynamic Modules project consists of several modules managed as separate Eclipse projects. In this step we will Import the core Spring-DM modules
spring-osgi-annotation
This is it. You project workspace should contain no errors and should look similar to this
![]()
Follow the same procedure to import more project into your workspace (i.e., samples, etc). Note: As you get more projects into your workspace, it is highly advisable to split projects into logical workind sets (see Eclipse documentation) for ease of management Launching Equinox inside the Eclipse IDEYou can run any of the unit and integration tests in the source tree simply by choosing "run as..." -> "JUnit test" from the context menu. You can also configure Eclipse to start up Equinox using the Spring-OSGi bundles. Follow directions provided in this short tutorial When you ready, start up equinox (you should see the "osgi>" prompt in the console window). Type 'ss' to see a short status summary of the bundles installed, and 'help' to get an overview of the commands available. |
|





Comments
exported services
Hi,
Thanks for the great documentation. A couple of questions:
When I run the command "bundle 9" on the console, it does not show SimpleService as having exported any services. Is this as specified. Here is the console output:
osgi> bundle 9
initial@reference:file:../../workspace/spring-osgi/samples/simple-service/simple-service-bundle/ [9]
Id=9, Status=ACTIVE Data Root=/home/john_brinnand/workspace/.metadata/.plugins/org.eclipse.pde.core/SimpleService in Equinox/org.eclipse.osgi/bundles/9/data
No registered services.
No services in use.
Exported packages
org.springframework.osgi.samples.simpleservice; version="0.0.0"[exported]
Imported packages
org.springframework.osgi.samples.simpleservice; version="0.0.0"
No fragment bundles
Named class space
org.springframework.osgi.samples.simpleservice; bundle-version="1.0.0"[provided]
No required bundles
Also, how can we run individual tests like testSimpleServiceExported?
Thanks,
John Brinnand
Last step: build with maven
I folowed the very good descripsion of Adrian but to me it looks like I'm missing one step: build the project with maven. So, I would say that after checking out the source code from svn you have to go the to root spring-osgi folder and run "mvn clean install". When ready you can perform the eclipse import steps.
Since the build process is using maven-osgi-plugin you have to have version 0.8.0-SNAPSHOT in your local repository. You can archive this by:
1. build it and install it by your own by following the http://cwiki.apache.org/FELIX/osgi-plugin-for-maven-2.html instructions (look for "Getting the maven-osgi-plugin")
2. editing spring-osgi/pom.xml, go at the end of the file and uncomment the plugin repository tag
No source code?
I don't want to appear dense, but when I check out the repository referred to in the link titled "Instructions for checking out the source are available", most of the projects seem to lacking any source code.
This upsets eclipse which complains with, e.g. "Package 'org.springframework.core' does not exist in this plug-in" for the project found in spring-osgi/spring-modules/spring-core.
What am I doing wrong?
No source code necessary
Your are doing nothing wrong. Most of the projects, as in your example spring-core, are there to allow that module of spring to be build as an osgi bundle. During the maven build process, a maven plugin is used to unpack the latest spring-core jar (for example) into the folder target/classes, and repackage them as an osgi bundle. This step is required till (as I understood) Spring 2.1 when the bundles will be available dirrectly as a spring dependency (Adrian, please correct me if I'm wrong). To run this process you have to go to spring-osgi root folder and start "mvn clean install"; when ready refresh Eclipse projects.
Define a classpath variable for your maven repository
this command:
mvn -Declipse.workspace=. eclipse:add-maven-repo
can not run in the command line
so I configure the eclipse from "Windows" -->"Preferences"-->"Java"-->"Build Path"--"Classpath Variables"-->"New..."