Installing and running Redberry


Pre-requirements

In order to install and use Redberry you need the following software installed on your system:

We highly recommend to use Redberry with IntelliJ IDEA which is an excellent open-source IDE for Groovy. IntelliJ IDEA provides a very versatile features for convenient usage of Redberry including syntax highlighting, code completion, documentation rendering, easy refactoring and many more.

In order to install and run Redberry with Intellij IDEA follow the instructions below:

  1. Download and install the latest Intellij IIDEA from the official website
  2. Open IntelliJ and create new Groovy project (File → NewProject, select Groovy):
  3. Ensure, that Project SDK is set to 1.7 (or higher), otherwise specify your JDK folder (New → JDK):
  4. Specify the Groovy installation:
  5. Press finish and IntelliJ will create a new project. Then create a new Groovy script:
  6. Add the following lines in the newly created file:
    @Grab(group = 'cc.redberry', module = 'groovy', version = '1.1.8')
    import cc.redberry.groovy.Redberry
    
  7. Put the cursor onto “Grab” and press Alt+Enter:
  8. Press “Grab the artifacts” and this will download Redberry and all required dependencies.
  9. After that you can run most Redberry scripts by simple wrapping Redberry code with the following:
    import cc.redberry.groovy.Redberry
    import static cc.redberry.groovy.RedberryPhysics.*
    import static cc.redberry.groovy.RedberryStatic.*
    import static cc.redberry.core.tensor.Tensors.*
     
    use(Redberry){
       //put your code here
    }
    
    (when IntelliJ installed Redberry, the first line with @Grab is no longer necessary)

Running Redberry in console script

You can run Redberry script directly in console. For this wrap your Redberry code like in the following example:

@Grab(group = 'cc.redberry', module = 'groovy', version = '1.1.9')
import cc.redberry.groovy.Redberry
import static cc.redberry.groovy.RedberryPhysics.*
import static cc.redberry.groovy.RedberryStatic.*
import static cc.redberry.core.tensor.Tensors.*
 
use(Redberry){
    //put your code here
    println Factor >> 'x**2 - y**2'.t
}
and simply run from the command line
> groovy MyRedberryScript.groovy

During the first run, Redberry and all required dependencies will be installed on the system (so the internet connection is required only for the first run).

Installing Redberry jar manually

You also can manually download Redberry all-in-one .jar from Downloads page and add it to your system classpath. Then you can run Redberry scripts without specifying @Grab in the first line.

Building Redberry and running tests

In order to build Redberry from sources first you need to install Apache Maven .

Then you need to obtain Redberry sources either by downloading from Bitbucket or by cloning Redberry repository (you need Mercurial):

> hg clone https://bitbucket.org/redberry/redberry
In order to build Redberry and run all tests run from the command line
> mvn clean install
In order to produce all-in-one .jar file run
> mvn clean install assembly:single
This will produce same file as one can download from Downloads page in target/ directory.