Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

...

Java SCA requires the following:

...

Code Block
svn checkout https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/sca

Anchor
Setup
Setup
Setting up your Development Environment

...

Code Block
svn checkout https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/sca

Building the SCA source code :

Code Block
mvn -Psetup clean installcd trunk
mvn -fae clean install

It should work even if you start with an empty Maven local repository, and it should always work, however when you are building for Tuscany for the first time there are a lot of dependencies which must be downloaded so the first build can take a long time and it may fail with problems retrieving the dependencies.

...

Info

The SCA build consumes a good amount of memory, in case you are seeing issues during the build, set a MAVEN_OPTS environment variable to allocate more memory for the build process.

Windows : SET MAVEN_OPTS="-Xmx512m
Unix : export -XX:MaxPermSize=384m"
Unix : export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=384m"

Info

If you are using MAC OS, please see 'Special instructions for MAC OS users' section below

Anchor
IDE
IDE
Importing SCA modules into your Development IDE

...

In order to generate the necessary project files to import the SCA modules to Eclipse, you can use the maven eclipse plugin

Code Block
mvn -fae -Peclipseeclipse:eclipse

Now , launch your Eclipse IDE, select File->Import->Existing projects into Workplace, and then import the project from SCA Modules into your Eclipse Workspace.

Using Eclipse PDE

To help with development in an OSGi environment Tuscany also has a build profile to setup the Eclipse Plugin Development Environment:

Code Block

mvn -fae -Peclipse

Now set Now, let's set the "Target Platform" in your Eclipse IDE by following the steps below :

  • Inside eclipse, select File->Open File" and open "distribution/all/target/features/tuscany.target"
    • click "Set as target platform" on the upper-right side of the overview window that opened

Then as when using eclipse:eclipse launch your Eclipse IDE, select File->Import->Existing projects into Workplace, and then import the project from SCA Modules into your Eclipse Workspace.

There are also some Tuscany Eclipse code templates available:
Eclipse Style Formatter There are also some Tuscany Eclipse code templates available:
Eclipse Style Formatter
Eclipse Templates

Anchor

...

Eclipse Build Troubleshooting
Eclipse Build Troubleshooting
Eclipse Build Troubleshooting

Sometimes a Maven build will work from the command line, yet the same component will not build in the Eclipse environment. Of course, developers try to prevent this from happening, but it does happen and makes for a valid Jira. In the meantime, here are some steps that might help correct build issues in the Eclipse environment:

  • Missing classpath variables - Sometimes Java build classpath variables are incorrect or missing, for instance "Unbound classpath variable: 'M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.9/jaxb-impl-2.1.9.jar'". Add the classpath variable 'M2_REPOS' to your workspace. Window > Preferences > Java > Build Path > Classpath variables. Create variables for any missing variables and point them to the appropriate place in your file system. Do a complete rebuild.
  • Missing projects - Sometimes developers add or remove project dependencies. These show up with error message "The project cannot be built until build path errors are resolved". This is often a sign that your Eclipse workspace is out of sync with your local repository or the svn repository. The full remedy is to refresh your local repos (svn update), rebuild your local repos (mvn clean install -U), regenerate Eclipse projects (mvn -Declipse), reimport projects in Eclipse, and clean/rebuild your projects. You may be able to do less than this full refresh with simple changes, but the full refresh is often needed for major changes.
  • Project won't build - Sometimes a particular project will not build despite repeated efforts. Consider if this project is necessary to the task at hand. You may be able to delete the problematic Eclipse project and continue with other work.

Anchor
MacOS
MacOS
Special instructions for MAC OS users

Some plugins used in the Tuscany build requires a explicit dependency on some classes from JDK tools.jar, which is in a different place in the MAC OS environment.

We have created duplicate profiles in Tuscany to accommodate the most used user tasks

  • Running a build : there is a default profile for the mac environment properly configuring the tools.jar property
    Code Block
    
       mvn clean install
    
  • Creating Eclipse IDE project files : there is a "eclipse-mac" profile
    Code Block
    
       mvn -Peclipse-mac
    

Update your maven settings.xml (%user_home%/.m2/settings.xml)

Updating your settings.xml with proper property configuration will make all profiles work in a MAC OS environment.

Code Block

<settings>

  <profiles>
     <profile>
        <id>mac-os-configuration</id>
        <properties>
           <tools.jar>${java.home}/../Classes/classes.jar</tools.jar>
        </properties>
     </profile>
  </profiles>
  
  <activeProfiles>
    <activeProfile>mac-os-configuration</activeProfile>
  </activeProfiles>

</settings>

Anchor
Coding Guidelines
Coding Guidelines
Coding Guidelines

There are a few simple guidelines when developing for JAVA SCA:

  • The basic coding style used is the described at Sun Java coding standards but the main thing is to be consistent with the existing code you're updating, so for example, if you're updating a method that uses the braces on the same line style don't add code with the hanging braces style.
  • Always

There are a few simple guidelines when developing for JAVA SCA:

  • The basic coding style used is the described at Sun Java coding standards but the main thing is to be consistent with the existing code you're updating, so for example, if you're updating a method that uses the braces on the same line style don't add code with the hanging braces style.
  • Always include the Apache License Headers on all files (both source code files and resource files such as xml documents)

...

Folder Names: Please use all lowercases and dashes in folder names (like in the jar names)

  • Maven artifact id = tuscany-<folder name>

Package names: Package names within modules should include the module name so that source code can be located in the source tree easily. So, for example, java/sca/module/implementation-java would be in package structure org.apache.tuscany.implementation.java.*

...

We use the term Module to refer to the leaf of maven tree.

  • sca/pom.xml's parent will be pom/parent/pom.xml
  • Other poms will use the pom from the parent folder as parent pom
  • Group id: org.apache.tuscany.sca
  • Version of our modules will be specified once in java/sca/pom.xml's parent will be pom/parent/pom.xml
  • Other poms will use the pom from the parent folder as parent pom
  • Group id: org.apache.tuscany.sca
  • Version of our modules will be specified once
  • , child poms don't need specify a version as they get it from their parent
  • pom names begin Apache Tuscany SCA
  • Eclipse projects are generated for all built modules using mvn eclipse:eclipse

Adding a new module and not ready to integrate?

'work-in-progress' modules can be worked on in the same source tree and yet not break the top-down build. You can do this by not listing your module(s) in java/sca/

...

modules/pom.xml.

Development Hints

Anchor
Samples in Eclipse
Samples in Eclipse
Importing existing Tuscany SCA projects into Eclipse

This section has talked about how to get set up ready to develop Tuscany. If you need to import existing samples into Eclipse to work on there are some instructions here. These are instructions for 1.x but should work OK on 2.x.

Adding a new module and not ready to integrate?

'work-in-progress' modules can be worked on in the same source tree and yet not break the top-down build. You can do this by not listing your module(s) in java/sca/modules/pom.xml.

...

Anchor
Webapp in Eclipse
Webapp in Eclipse
Generating Eclipse WTP Web Projects for Webapp samples

...

The magic -Dwtpversion=1.5 option will add the WTP Web project nature to
all the Eclipse projects with <packaging>war</packaging> in their Maven
pom.xml. You'll then be able to add these projects to a WTP Tomcat or
Geronimo Server configuration, to publish and run them straight from
your Eclipse workspace.h3:

Anchor
Ant
Ant
Generating Dependencies for Ant in Samples

Figuring out the package dependency to include in Ant build.xml can be a pain. Here is a quick
script which works in Linux environment for war files.

Code Block
jar tvf sample-feed-aggregator-webapp.war | grep .jar | awk '{ printf "%s\n", $8 }' |
   sed -e "s/WEB-INF\/lib\///" | awk '{ printf "<include name=\"%s\"/>\n", $1 }' | grep -v tuscany

...