Difference between revisions of "Orion/Getting the source"

From Eclipsepedia

Jump to: navigation, search
(Running the tests)
(Node.js on local computer)
Line 96: Line 96:
#Run the <code>npm install</code> command to automatically download Orionode's dependencies.
#Run the <code>npm install</code> command to automatically download Orionode's dependencies.
#*If you're not interested in developing the server, you can instead run <code>npm install --production</code>, which omits the dev-time dependencies for a smaller download.
#*If you're not interested in developing the server, you can instead run <code>npm install --production</code>, which omits the dev-time dependencies for a smaller download.
=== Running the tests ===
Our Node server unit tests are written against the [http://visionmedia.github.com/mocha/ Mocha] test framework.
From the <code>org.eclipse.orion.client/modules/orionode</code> directory, just run the command:
  npm test
This will invoke Mocha and produce console output showing which tests passed and failed.
If you want to pass custom arguments to Mocha, you'll need to invoke it explicitly like this:
  ./node_modules/mocha/bin/mocha [debug] [options] [files]
To make this easier, you can install Mocha as a global npm package (<code>npm install mocha -g</code>), and then invoke it as simply <code>mocha</code> from a command shell.
=== Writing more tests ===
When you're prototyping a new feature, writing unit tests for it is always a good idea. Here's how to write a test:
# Create a new file <code>my_tests.js</code> in the <code>org.eclipse.orion.client/modules/orionode/test/</code> directory.
# Write your tests in the file. Here are two resources to help you get started:
#* [http://visionmedia.github.com/mocha/ Mocha reference]: the general structure of a test.
#* [http://visionmedia.github.com/superagent/ Superagent reference]: how to write concise assertions for testing HTTP.
# [[# Running the tests|Run the tests]].
#* You don't have to register your new tests with the framework; it will discover anything in the <code>test/</code> directory automatically.
Helper data or classes should go in <code>test/support/</code>.
=== Concatenation and Minification ===
=== Concatenation and Minification ===
Line 127: Line 103:
Clear your browser cache. The next time you load Orionode, it should be much faster.
Clear your browser cache. The next time you load Orionode, it should be much faster.
=== Running tests ===
The Orion node server has its own test suite. See [[Orion/Running_the_tests#Node.js_Server_Tests]] for more details
== References ==
== References ==

Revision as of 14:16, 8 February 2013

This page covers how to get the Orion source code, as well as how to set up for self-hosting (changing Orion code from Orion) using an Eclipse development environment.


What you need

Browsing the source

Just want to take a peek at our code? You can browse it on the web here:

We also have GitHub mirrors if you prefer:

Getting the source onto your computer

The Orion source code lives in two Git repositories:

To checkout our repositories, you'll generally perform the following commands in your command shell:

git clone http://git.eclipse.org/gitroot/orion/org.eclipse.orion.client.git
git clone http://git.eclipse.org/gitroot/orion/org.eclipse.orion.server.git

If you're running an older version of Git, the http protocol may not work. In that case, try the git protocol instead:

git clone git://git.eclipse.org/gitroot/orion/org.eclipse.orion.client.git
git clone git://git.eclipse.org/gitroot/orion/org.eclipse.orion.server.git

Notes for Eclipse committers

This section applies only to Eclipse Committers. If you're not a committer, you can skip these instructions.

  • Ensure that your Git configuration uses the same email address that you've set in your Eclipse Foundation profile. If the addresses don't match, you won't be able to push changes (see Git#Committers_new_to_Git).
  • Committers need to use different URLs to access the Orion Git repositories. The URL includes your committer ID:

Overview of self-hosting

To edit Orion's own source code using Orion, there's two fundamentally different ways we can do it. Here are our options:

Pure cloud.
Using a cloud deployment of Orion (like OrionHub, a public Orion server that anyone can use), you checkout the Orion source code using Orion's built-in Git features, then edit and test it. There's no software install; all you need is a web browser. Since you don't control the server, this method only allows you to hack on the Orion client code. See Selfhosting for instructions.

Local computer using Eclipse IDE.
This method requires the Eclipse IDE and a build of Orion. On your local computer, you checkout the Orion source code, and launch the Orion server from your Eclipse IDE. You can develop both client-side and server-side code using this method. Git functionality can be provided by any Git client (Orion's built-in Git features, or EGit, or msysgit on Windows, or the native command-line Git client, etc). This method is more complex, but also more flexible.
Local computer using Node.js
This method use Node.js to run a local Orion server, with Orion development tools running in the browser.

Local computer with Eclipse IDE

Self-hosting locally involves running an Orion server on localhost, pointing your Orion editor at your local Git repo directories, and working within Orion to make changes. Changes are committed using any Git client; for instructions on Orion's Git features, see Working with git.

Here are the steps needed to get up and running.

Install the Eclipse SDK

  • You can use any recent stable build of the Eclipse SDK to run the server, such as Eclipse 4.2.1.
  • Optionally install the Eclipse Git tools via Help > Install New Software. Select the Juno repository and search for 'Eclipse EGit' to find the package.

Load the source into Eclipse

  • Download a stable orion build (latest integration build is the current recommendation) and unpack it somewhere on your hard disk. This download will be used as a so-called "target platform" when you run the server from Eclipse.
    • Occasionally, new dependencies are introduced in the server and you will need to take a nightly build to keep up-to-date. Check the orion-dev mailing list if you aren't sure which build to take.
  • Create a new workspace using your Eclipse SDK.
  • Use the File->Import->General->Existing Projects into Workspace wizard. In the wizard, set the root directory for the import to whatever directory you used when you cloned the Git repositories. You'll know you have the right path when you see a bunch of org.eclipse.orion.* projects in the project list.
  • Ensure that Copy projects into workspace is not checked. Feel free to import just a subset of the projects (for example, just client plugins) - the remaining ones will come from the 'target platform'.
  • The projects should appear in your workspace. Don't worry about compile errors just yet until after you've set up the target platform.
  • Now you need to set up a target that points to the Orion build you downloaded. (Window->Preferences->Plug-in Development->Target Platform).
    • Add a target
    • Initialize the target definition with "Nothing", Next...
    • In the Locations tab, click Add... , Select Installation, click "Next", click "Browse...", and point to the eclipse directory of your stable Orion build
    • Once you finish the wizard, you'll have a new target definition available in the list of targets.
    • Make this the active target definition for your self-hosting workspace.
  • Your workspace will be rebuilt and most of the compile errors should disappear.
    • There might be a few errors related to unsatisfied dependencies from .tests plugins, but you can ignore them for now. You can also ignore any errors from org.eclipse.orion.server.ui, as it is not required to launch the server. Right-click these projects and close them if you get sick of seeing the errors.

Set up the launch to run from source

The plugin source you've loaded into Eclipse will now be used to run Orion, taking priority over the plugins in the working stable build.

  • Open the Run->Run Configurations dialog, expand OSGi Framework, and select the OSGi Framework launch called web-ide.
  • The launch configuration we will use is associated with a Orion server configuration file called web-ide.conf. This file controls which directories the Orion server can access on your machine, among other things. Since we want to use Orion to edit its own source code, we have to ensure the Orion server can access the files in your local git repo.
    • Add a line like this to web-ide.conf:
      The path points to the folder where you checked out the Orion source code. (Windows paths must be separated with double backslashes!)
  • On the Bundles tab, ensure that "Launch with: features selected below" is selected. Ensure there are five Orion features checked (see image below)


  • If you only want to work on the client (not the server), you can now close the server projects (5 client projects should remain).

Run the server

  • Run the launch configuration (click the Run button from the launch configuration dialog, or use the Run command on the Eclipse toolbar.)
  • Point your browser at http://localhost:8080.
  • You'll be prompted to login (create an account).
  • Once logged in, you'll see an empty Navigator view. Click the New button and choose Link to Server.
  • Type a name (for example, "Orion Client") and in the Server Path field, enter the path to the Orion code on your local machine.
    • The path must be of one of the orion.file.allowedPaths entries we created in the previous section (or a subfolder thereof).
    • For example, if you wanted to make changes to the client, you might link to the following file path:
  • You should see the folders show up in your Orion explorer:
  • From here, you can start editing files. As you make changes to the client code, you can simply reload the corresponding page in your browser to see the changes. We recommend you keep a browser tab open with a stable editor and stable navigator, and open a new tab for reloading and trying changes. In this way, you'll always have a couple of safe browser tabs to use to revert changes if you break something!

Node.js on local computer

Installing from source

  1. Make sure you have Node.js and npm installed. See nodejs.org for details.
  2. Get the Orion source. You only need to get the client source.
  3. Open a command shell and change directory to org.eclipse.orion.client/modules/orionode.
  4. Run the npm install command to automatically download Orionode's dependencies.
    • If you're not interested in developing the server, you can instead run npm install --production, which omits the dev-time dependencies for a smaller download.

Concatenation and Minification

By default the pages served up by Orionode are not concatenated or minified, so they will load rather slowly. You can mitigate this by running the client-side build. To do this, just run build.js, found in the org.eclipse.orion.client/modules/orionode/build directory:

 node ./build/build.js
Running the script will overwrite files in your working directory! Make sure anything important is committed to a branch first.

Clear your browser cache. The next time you load Orionode, it should be much faster.

Running tests

The Orion node server has its own test suite. See Orion/Running_the_tests#Node.js_Server_Tests for more details


Contributing to Orion

See the Releng Builds page for details on how to contribute changes to the build.

See also