====== Installing and running Redberry ====== ---- ===== Pre-requirements ===== In order to install and use Redberry you need the following software installed on your system: * JDK version 7 or higher, download from [[http://www.oracle.com/technetwork/java/javase/downloads/index.html|Oracle website]] * Groovy version 2.0 or higher, download from the [[http://groovy.codehaus.org/Download|official website]] * (optional) IntelliJ IDEA for convenient scripts editing, download from the [[http://www.jetbrains.com/idea/download/index.html|official website]] ===== Installing and using Redberry with IntelliJ IDEA (recommended) ===== 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: - Download and install the latest Intellij IIDEA from the [[http://www.jetbrains.com/idea/download/|official website]] - Open IntelliJ and create new Groovy project (File -> NewProject, select Groovy): {{::ideanewproject.png?625|}} - Ensure, that Project SDK is set to 1.7 (or higher), otherwise specify your JDK folder (New -> JDK):{{::ideaspecifysdk.png?700|}} - Specify the Groovy installation:\\ {{::ideaspecifygroovy.png?720|}} - Press finish and IntelliJ will create a new project. Then create a new Groovy script:{{::ideanewgroovyscript.png?500|}} - Add the following lines in the newly created file: @Grab(group = 'cc.redberry', module = 'groovy', version = '1.1.8') import cc.redberry.groovy.Redberry - Put the cursor onto "Grab" and press Alt+Enter:{{::ideagrab.png?500|}} - Press "Grab the artifacts" and this will download Redberry and all required dependencies. - 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|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 [[http://maven.apache.org|Apache Maven]] . Then you need to obtain Redberry sources either by downloading from [[https://bitbucket.org/redberry/redberry/downloads|Bitbucket]] or by cloning Redberry repository (you need [[http://mercurial.selenic.com|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.