Pavel Orekhov
Pavel Orekhov

Reputation: 2194

How do I build Cassandra from GitHub source?

I found this repo on github: https://github.com/apache/cassandra

And I would like to import it into intellij and build it in order to run some code locally that I want to build on top of this github code. But there are no instructions for building it.

Where are the instructions?

Upvotes: 3

Views: 440

Answers (2)

Sridhar Sarnobat
Sridhar Sarnobat

Reputation: 25286

Worked for me (on a88ff20469) using Mac.

Basic Build

JAVA_HOME=/opt/homebrew/Cellar/openjdk@11/11.0.25/ ant build  -Duse.jdk11=true
set-cqlsh-version:

_createVersionPropFile:
    [mkdir] Created dir: /Volumes/git/github/cassandra/src/resources/org/apache/cassandra/config
[propertyfile] Creating new property file: /Volumes/git/github/cassandra/src/resources/org/apache/cassandra/config/version.properties
     [copy] Copying 20 files to /Volumes/git/github/cassandra/build/classes/main
     [copy] Copying 1 file to /Volumes/git/github/cassandra/conf

build:

BUILD SUCCESSFUL
Total time: 36 seconds

As someone who likes "old" tools rather than just pointless reinvention of the wheel, I was surprised that ant was still used. Thankfully it's easy.

Full Build

This will create javadoc, install a maven artifact and other stuff I've not yet found out.

JAVA_HOME=/opt/homebrew/Cellar/openjdk@11/11.0.25/ ant mvn-install  -Duse.jdk11=true
     [exec] [INFO] --- install:2.3.1:install-file (default-cli) @ standalone-pom ---
     [exec] [INFO] Installing /Volumes/git/github/cassandra/build/apache-cassandra-5.1-SNAPSHOT-javadoc.jar to /Users/sarnobat/.m2/repository/org/apache/cassandra/cassandra-all/5.1-SNAPSHOT/cassandra-all-5.1-SNAPSHOT-javadoc.jar
     [exec] [INFO] Installing /Volumes/git/github/cassandra/build/apache-cassandra-5.1-SNAPSHOT.pom to /Users/sarnobat/.m2/repository/org/apache/cassandra/cassandra-all/5.1-SNAPSHOT/cassandra-all-5.1-SNAPSHOT.pom
     [exec] [INFO] ------------------------------------------------------------------------
     [exec] [INFO] BUILD SUCCESS
     [exec] [INFO] ------------------------------------------------------------------------
     [exec] [INFO] Total time:  0.176 s
     [exec] [INFO] Finished at: 2024-12-27T16:36:43-05:00
     [exec] [INFO] ------------------------------------------------------------------------

BUILD SUCCESSFUL
Total time: 41 seconds

You'll get an artifact here:

~/.m2/repository/org/apache/cassandra/cassandra-all/5.1-SNAPSHOT/cassandra-all-5.1-SNAPSHOT.jar

Running

bin/cassandra -f

This will create the following process:

64136 ttys001    0:09.32 /usr/bin/java -ea -da:net.openhft... -XX:+UseThreadPriorities -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+AlwaysPreTouch -XX:+UseTLAB -XX:+ResizeTLAB -XX:+UseNUMA -XX:+PerfDisableSharedMem -Djava.net.preferIPv4Stack=true -Dchronicle.analytics.disable=true -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxTenuringThreshold=1 -XX:G1HeapRegionSize=16m -XX:G1RSetUpdatingPauseTimePercent=5 -XX:MaxGCPauseMillis=300 -XX:InitiatingHeapOccupancyPercent=70 -Djdk.attach.allowAttachSelf=true --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED --add-exports java.management/com.sun.jmx.remote.security=ALL-UNNAMED --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED --add-exports java.sql/java.sql=ALL-UNNAMED --add-exports java.base/java.lang.ref=ALL-UNNAMED --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.math=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -Dio.netty.allocator.useCacheForAllThreads=true -Dio.netty.allocator.maxOrder=11 --add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED -Xlog:gc=info,heap*=trace,age*=debug,safepoint=info,promotion*=trace:file=/Volumes/git/github/cassandra/bin/../logs/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10485760 -Xms8192M -Xmx8192M -XX:CompileCommandFile=/Volumes/git/github/cassandra/bin/../conf/hotspot_compiler -javaagent:/Volumes/git/github/cassandra/bin/../lib/jamm-0.4.0.jar -Dcassandra.jmx.local.port=7199 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password -XX:OnOutOfMemoryError=kill -9 %p -Dlogback.configurationFile=logback.xml -Dcassandra.logdir=/Volumes/git/github/cassandra/bin/../logs -Dcassandra.storagedir=/Volumes/git/github/cassandra/bin/../data -cp /Volumes/git/github/cassandra/bin/../conf:/Volumes/git/github/cassandra/bin/../build/apache-cassandra-5.1-SNAPSHOT.jar:/Volumes/git/github/cassandra/bin/../lib/HdrHistogram-2.1.12.jar:/Volumes/git/github/cassandra/bin/../lib/ST4-4.0.8.jar:/Volumes/git/github/cassandra/bin/../lib/affinity-3.23.3.jar:/Volumes/git/github/cassandra/bin/../lib/agrona-1.17.1.jar:/Volumes/git/github/cassandra/bin/../lib/airline-0.8.jar:/Volumes/git/github/cassandra/bin/../lib/antlr-runtime-3.5.2.jar:/Volumes/git/github/cassandra/bin/../lib/asm-9.4.jar:/Volumes/git/github/cassandra/bin/../lib/big-math-2.3.0.jar:/Volumes/git/github/cassandra/bin/../lib/caffeine-3.1.8.jar:/Volumes/git/github/cassandra/bin/../lib/cassandra-driver-core-3.11.5-shaded.jar:/Volumes/git/github/cassandra/bin/../lib/chronicle-bytes-2.23.33.jar:/Volumes/git/github/cassandra/bin/../lib/chronicle-core-2.23.36.jar:/Volumes/git/github/cassandra/bin/../lib/chronicle-queue-5.23.37.jar:/Volumes/git/github/cassandra/bin/../lib/chronicle-threads-2.23.25.jar:/Volumes/git/github/cassandra/bin/../lib/chronicle-wire-2.23.39.jar:/Volumes/git/github/cassandra/bin/../lib/commons-cli-1.5.0.jar:/Volumes/git/github/cassandra/bin/../lib/commons-lang3-3.13.0.jar:/Volumes/git/github/cassandra/bin/../lib/commons-math3-3.2.jar:/Volumes/git/github/cassandra/bin/../lib/concurrent-trees-2.4.0.jar:/Volumes/git/github/cassandra/bin/../lib/ecj-3.33.0.jar:/Volumes/git/github/cassandra/bin/../lib/failureaccess-1.0.1.jar:/Volumes/git/github/cassandra/bin/../lib/guava-32.0.1-jre.jar:/Volumes/git/github/cassandra/bin/../lib/high-scale-lib-1.0.6.jar:/Volumes/git/github/cassandra/bin/../lib/hppc-0.8.1.jar:/Volumes/git/github/cassandra/bin/../lib/ipaddress-5.3.3.jar:/Volumes/git/github/cassandra/bin/../lib/j2objc-annotations-1.3.jar:/Volumes/git/github/cassandra/bin/../lib/jackson-annotations-2.15.3.jar:/Volumes/git/github/cassandra/bin/../lib/jackson-core-2.15.3.jar:/Volumes/git/github/cassandra/bin/../lib/jackson-databind-2.15.3.jar:/Volumes/git/github/cassandra/bin/../lib/jackson-datatype-jsr310-2.15.3.jar:/Volumes/git/github/cassandra/bin/../lib/jamm-0.4.0.jar:/Volumes/git/github/cassandra/bin/../lib/javax.inject-1.jar:/Volumes/git/github/cassandra/bin/../lib/jbcrypt-0.4.jar:/Volumes/git/github/cassandra/bin/../lib/jcl-over-slf4j-1.7.36.jar:/Volumes/git/github/cassandra/bin/../lib/jcommander-1.30.jar:/Volumes/git/github/cassandra/bin/../lib/jctools-core-3.1.0.jar:/Volumes/git/github/cassandra/bin/../lib/jffi-1.3.11-native.jar:/Volumes/git/github/cassandra/bin/../lib/jffi-1.3.11.jar:/Volumes/git/github/cassandra/bin/../lib/jna-5.13.0.jar:/Volumes/git/github/cassandra/bin/../lib/jna-platform-5.13.0.jar:/Volumes/git/github/cassandra/bin/../lib/jnr-a64asm-1.0.0.jar:/Volumes/git/github/cassandra/bin/../lib/jnr-constants-0.10.4.jar:/Volumes/git/github/cassandra/bin/../lib/jnr-ffi-2.2.13.jar:/Volumes/git/github/cassandra/bin/../lib/jnr-x86asm-1.0.2.jar:/Volumes/git/github/cassandra/bin/../lib/jsr305-2.0.2.jar:/Volumes/git/github/cassandra/bin/../lib/jvector-1.0.2.jar:/Volumes/git/github/cassandra/bin/../lib/jvm-attach-api-1.5.jar:/Volumes/git/github/cassandra/bin/../lib/log4j-over-slf4j-1.7.36.jar:/Volumes/git/github/cassandra/bin/../lib/logback-classic-1.2.12.jar:/Volumes/git/github/cassandra/bin/../lib/logback-core-1.2.12.jar:/Volumes/git/github/cassandra/bin/../lib/lucene-analysis-common-9.12.0.jar:/Volumes/git/github/cassandra/bin/../lib/lucene-core-9.12.0.jar:/Volumes/git/github/cassandra/bin/../lib/lz4-java-1.8.0.jar:/Volumes/git/github/cassandra/bin/../lib/metrics-core-4.2.19.jar:/Volumes/git/github/cassandra/bin/../lib/metrics-jvm-4.2.19.jar:/Volumes/git/github/cassandra/bin/../lib/metrics-logback-4.2.19.jar:/Volumes/git/github/cassandra/bin/../lib/mxdump-0.14.jar:/Volumes/git/github/cassandra/bin/../lib/netty-all-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-buffer-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-codec-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-common-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-handler-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-handler-proxy-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-handler-ssl-ocsp-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-resolver-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-tcnative-boringssl-static-2.0.61.Final-linux-aarch_64.jar:/Volumes/git/github/cassandra/bin/../lib/netty-tcnative-boringssl-static-2.0.61.Final-linux-x86_64.jar:/Volumes/git/github/cassandra/bin/../lib/netty-tcnative-boringssl-static-2.0.61.Final-osx-aarch_64.jar:/Volumes/git/github/cassandra/bin/../lib/netty-tcnative-boringssl-static-2.0.61.Final-osx-x86_64.jar:/Volumes/git/github/cassandra/bin/../lib/netty-tcnative-boringssl-static-2.0.61.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-tcnative-classes-2.0.61.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-transport-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-transport-classes-epoll-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-transport-classes-kqueue-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-transport-native-epoll-4.1.113.Final-linux-aarch_64.jar:/Volumes/git/github/cassandra/bin/../lib/netty-transport-native-epoll-4.1.113.Final-linux-x86_64.jar:/Volumes/git/github/cassandra/bin/../lib/netty-transport-native-epoll-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/netty-transport-native-unix-common-4.1.113.Final.jar:/Volumes/git/github/cassandra/bin/../lib/ohc-core-0.5.1.jar:/Volumes/git/github/cassandra/bin/../lib/ohc-core-j8-0.5.1.jar:/Volumes/git/github/cassandra/bin/../lib/oshi-core-6.4.8.jar:/Volumes/git/github/cassandra/bin/../lib/passay-1.6.4.jar:/Volumes/git/github/cassandra/bin/../lib/posix-2.24ea4.jar:/Volumes/git/github/cassandra/bin/../lib/psjava-0.1.19.jar:/Volumes/git/github/cassandra/bin/../lib/semver4j-3.1.0.jar:/Volumes/git/github/cassandra/bin/../lib/sjk-cli-0.14.jar:/Volumes/git/github/cassandra/bin/../lib/sjk-core-0.14.jar:/Volumes/git/github/cassandra/bin/../lib/sjk-json-0.14.jar:/Volumes/git/github/cassandra/bin/../lib/sjk-stacktrace-0.14.jar:/Volumes/git/github/cassandra/bin/../lib/slf4j-api-1.7.36.jar:/Volumes/git/github/cassandra/bin/../lib/snakeyaml-2.1.jar:/Volumes/git/github/cassandra/bin/../lib/snappy-java-1.1.10.4.jar:/Volumes/git/github/cassandra/bin/../lib/stream-2.5.2.jar:/Volumes/git/github/cassandra/bin/../lib/zstd-jni-1.5.5-1.jar:/Volumes/git/github/cassandra/bin/../lib/jsr223/*/*.jar: org.apache.cassandra.service.CassandraDaemon

For logging:

logs/system.log

Other notes

  • You might think it's worth running the maven commands directly but so far I've found it more trouble than it's worth.
  • Run server in test mode: JAVA_HOME=/opt/homebrew/Cellar/openjdk@11/11.0.25/ ant test-run

Upvotes: 0

Erick Ramirez
Erick Ramirez

Reputation: 16353

Thank you for taking interest in writing Cassandra code.

The instructions for building Cassandra from source code including IDE integration is documented in the Contributing to Cassandra page on the official Apache Cassandra website. There are instructions for IntelliJ, NetBeans and Eclipse.

It's not as straightforward as we would like because everyone's laptop/desktop is different so I would recommend you join the ASF Slack to get help in real-time from other Cassandra contributors in the #cassandra-dev channel. For details, see the Community section of the Cassandra website. Cheers!


👉 Please support the Apache Cassandra community by hovering over then click on the Watch tag button. 🙏 Thanks!

Upvotes: 3

Related Questions