If you are going to do any Java development, you’ll want to install the latest version of Eclipse. There are several flavors of eclipse available. We recommend you download the Eclipse IDE for Java Developers. For Python/Jython development, installing PyDev is also highly recommended.

All files need to be interpreted as UTF-8. This only affects one file in core currently, and you’d know it because it will make the unit tests fail if you run them in Eclipse. To change it, go to Preferences | General | Workspace, and change the Text File Encoding to UTF-8. This is the same as ASCII for characters codes less than 128 so it should be backwards-compatible with the rest of our files.

Asserts in Java are not enabled by default (and thus not enabled in Eclipse). To enable them, go to Preferences | Java | Installed JREs and change the 1.8 JVMs to use “-ea” as the default VM arguments.

You will also need to change some settings so that source files are formatted properly when viewed outside of the Eclipse IDE. (Diff tools, emacs, etc.) Go to Preferences – General – Editors – Text Editors, change the “Displayed tab width” option to “4”, and check the “Insert spaces for tabs” option. These are all per-workspace settings, so you will only have to repeat them if you create a new workspace.

Also, to use the asserts, use either of the following:

assert booleanexpressionthatshouldbetrue
assert booleanexpressionthatshouldbetrue : "your message here if it fails"

You can run more than one instance of Eclipse if you run open -n /path/to/Eclipse.app from Terminal.

Install PyDev

First, install PyDev (minimum version 4.3.0). Next, open up the Eclipse preferences page, go to PyDev | Interpreters – Jython, and click New…. Name it CycleServer (note: this name is required) and navigate to the system/jython/jython.jar file in your CycleServer installation. PyDev will scan the file and prompt you for the directories to use. It usually preselects the right ones (the ones that are directories in CycleServer). It also may include others like __classpath__ and the pydev plugin inside Eclipse, which should not be selected. Click OK and then OK again. This configures your workspace so you don’t have to repeat those steps per project. For more detailed information on installing Eclipse + PyDev see Lars Vogel’s excellent tutorial.

Now configure the Jython interpreter to use Python predef files that with your CycleServer installation. These predef files are skeleton definitions of modules and methods implemented by CycleServer plugins. Without adding these predefs, Eclipse will display errors for imports of code implemented by CycleServer plugins.

  1. open up the Eclipse preferences page, go to PyDev | Interpreters – Jython.
  2. Find the Predefined tab and click New
  3. Add the path CS_HOME/system/jython/predef and click Apply

If you receive an error message like “Unable to get info on the interpreter” when trying to add CycleServer’s jython.jar, it is likely that your current user does not have full read/write access to all the files in your CycleServer installations. Simply, run sudo chmod -R 777
/path/to/cycle_server
and try to add system/jython/jython.jar again.

Import an Existing Plugin Project into Eclipse

In order to import an existing component, first clone it from the respective source repository:

git clone https://git.example.com/....

Next, we need to create the Eclipse project, which is done with Gradle.

If you have not done so already, initialize Gradle for working with CycleServer components:

$ $CS_HOME/util/devel initialize

Next, generate the project files for eclipse:

$ gradle eclipse

Next, import the project into eclipse as a eclipse project:

File -> Import -> Existing Projects into Workspace

Specify the component directory as the root directory. This will list your component in the Projects: list. Click Finish. The project should be added to the Package Explorer view.

Building a Component

First, go to the directory with the contents of the component. This should have a build.gradle file as well as a src/main/component directory. The minimum build.gradle file consists of the following:

apply plugin: 'cycle'

You can optionally include a version for your component:

apply plugin: 'cycle'
version = '1.0'

Note

There currently is a bug in dependency resolution for the cycle plugin that requires you to add the following snippet to your build.gradle file

repositories {  mavenCentral() }

You should then be able to build components:

gradle build

This will create a zip file in build/distributions. This zip file can be installed into CycleServer by copying it into the components directory in your CycleServer installation. Once successfully loaded, the zip file will be deleted from components.

The easiest way to load your component into CycleServer is to run the deploy command:

gradle deploy

This will build the component (skipping the tests), and copy the zip into the CycleServer location defined in your gradle.properties file.

The source directory structure consists of the following:

Directory Purpose
src/main/component Files that get packaged directly into the zip
src/main/component/plugins Python or Javascript plugins
src/main/python Python code (non-plugins)
src/main/java Java code (compiled into a JAR automatically)
src/main/component/lib/python Python libraries (expanded or zip files)
src/main/component/lib/java External Java dependencies (jar files)

To quickly create those directories, run the following command from the command-line:

$ mkdir -p src/main/component/plugins src/main/component/lib/{python,java}