IDEA is now open source! The free community edition at http://www.jetbrains.org is all you need for Cassandra development. (You don't need J2EE or Web tools.)
To quickly import Cassandra into IntelliJ and start coding simply:
- Run "ant generate-eclipse-files"
File -> Import Project
(The IntelliJ Eclipse plugin must be enabled.)
If you want IDEA to handle more of the environment for you, keep reading.
Setup Cassandra as a Project
Clone Cassandra from apache's Git repository.
for trunk branch (JDK7 required)
git clone git://git.apache.org/cassandra.gitfor cassandra-1.2 branch
git clone –b cassandra-1.2 git://git.apache.org/cassandra.git
- Once git has finished cloning the repository, generate the eclipse files using ant.
- Start IDEA
Click Import Project.
Navigate to the newly cloned cassandra directory and click OK.
Select Import project from external model, pick Eclipse then click OK.
Select cassandra and click Finish. You now have a successfully imported Cassandra project.
Building & Testing Cassandra via Ant
To build Cassandra we need to import ant's build file, aka build.xml.
Select the Ant Build tab from IDEA (right hand side in the screen shot below).
Select the + (Add).
Navigate to Cassandra's root directory (based on the tutorial this would be ~/workspace/cassandra/) and select build.xml.
Click OK. The different ant targets will now be available for execution.
Building / Testing Cassandra via Ant
Once the ant build file is added to IDEA you can compile cassandra via the build target. The unit tests are located under the test target.
To run a target select it and then click .
Create a RUN configuration
Select Run > Edit Configurations... and click the + (Add New Configuration).
Populate the config with the following:
Main class: org.apache.cassandra.service.CassandraDaemon VM options: -Dcassandra-foreground=yes -Dcassandra.config=@@@ -ea -Xmx1G Note -Dcassandra.config you want to replace @@@ with the full path to your cassandra.yaml config file (located in <cassandra_dir>/conf/cassandra.yaml) eg: file:////Users/user/workspace/cassandra/conf/cassandra.yaml
Verify Cassandra is running via IDEA
If everything is configured correctly, when you run Cassandra (via or Run > Run...) logs should appear in the IDEA console.
Once cassandra is started, you can also check it's up and running by connecting to it via cqlsh
$ ./cqlsh Connected to Test Cluster at localhost:9160. [cqlsh 3.1.8 | Cassandra 1.2.11-SNAPSHOT | CQL spec 3.0.0 | Thrift protocol 19.36.1] Use HELP for help. cqlsh>
Dont forget to update IntelliJ to use JDK7 or later for Cassandra versions greater than Cassandra 1.2