Skip to content
Permalink
Browse files
Gradle can now generate Deb packages, RPMs and Docker containers
Patch by Jon Haddad; Reviewed by Jake Luciani and Dinesh Joshi for CASSANDRASC-14
  • Loading branch information
rustyrazorblade committed Apr 23, 2020
1 parent c2d684d commit 14770b6921f0dcc801a2428da65e41553d13ada4
Showing 3 changed files with 81 additions and 3 deletions.
@@ -12,6 +12,12 @@ aliases:
working_directory: ~/repo
environment:
TERM: dumb
centos: &centos
docker:
- image: centos:centos8
working_directory: ~/repo
environment:
TERM: dumb

# we might modify this in the future to accept a parameter for the java package to install
commands:
@@ -76,6 +82,35 @@ jobs:
- store_test_results:
path: ~/repo/build/test-results/

# ensures we can build and install deb packages
deb_build_install:
<<: *base_job
steps:
- checkout
- install_common
- install_java:
version: adoptopenjdk-11-hotspot
- run: ./gradlew buildDeb
- run: DEBIAN_FRONTEND=noninteractive sudo apt install -y ./build/distributions/cassandra-sidecar*.deb
- run: test -f /opt/cassandra-sidecar/bin/cassandra-sidecar

# ensures we can build and install rpm packages
rpm_build_install:
<<: *centos
steps:
- checkout
- run: yum install -y java-11-openjdk-devel # the image uses root by default, no need for sudo
- run: JAVA_HOME=/usr/lib/jvm/java-11-openjdk ./gradlew buildRpm
- run: yum install -y ./build/distributions/cassandra-sidecar*.rpm
- run: test -f /opt/cassandra-sidecar/bin/cassandra-sidecar

docker_build:
<<: *base_job
steps:
- checkout
- run: ./gradlew jibDockerBuild


workflows:
version: 2

@@ -85,4 +120,10 @@ workflows:

test_java_11:
jobs:
- java11
- java11

test_packaging:
jobs:
- deb_build_install
- rpm_build_install
- docker_build
@@ -15,10 +15,15 @@ plugins {
id 'jacoco'
id "com.github.spotbugs" version "3.0.0"
id 'org.hidetake.swagger.generator' version '2.16.0'

// https://github.com/nebula-plugins/gradle-ospackage-plugin/wiki
id "nebula.ospackage" version "8.3.0"
id 'nebula.ospackage-application' version "8.3.0"
id 'com.google.cloud.tools.jib' version '2.2.0'
}

group 'org.apache.cassandra'
version '1.0-SNAPSHOT'
version project.version

sourceCompatibility = 1.8

@@ -28,7 +33,7 @@ repositories {

// Take the application out once we're running via Cassandra
mainClassName = "org.apache.cassandra.sidecar.CassandraSidecarDaemon"
applicationName = 'CassandraSidecarDaemon'
applicationName = 'cassandra-sidecar'

// Config file location should be in file:/// format for local files,
def confFile = "file:" + File.separator + File.separator + "APP_HOME_TO_REPLACE/conf/sidecar.yaml"
@@ -177,6 +182,37 @@ tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports.html.enabled = true
}

/**
* General configuration for linux packages.
* Can be overridden in the buildRpm and buildDeb configuration
* We can put dependencies here, such as java, but unfortunately since java is distributed
* in an inconsistent manner depending on the version you want (8 vs 11) we can't include Java
* as a requirement without the install breaking if you want to use a different version
*/
ospackage {
packageName = "cassandra-sidecar"
version = project.version
// ospackage puts packages into /opt/[package] by default
// which is _technically_ the right spot for packages
link("/usr/local/bin/cassandra-sidecar", "/opt/cassandra-sidecar/bin/cassandra-sidecar")
license "Apache License 2.0"
description "Sidecar Management Tool for Apache Cassandra"
os = LINUX
user "root"
}

buildRpm {
group = "build"
}

buildDeb {
group = "build"
}

applicationDistribution.from("LICENSE.txt") {
into ""
}

// copyDist gets called on every build
copyDist.dependsOn installDist, copyJolokia
check.dependsOn checkstyleMain, checkstyleTest, integrationTest, jacocoTestReport
@@ -0,0 +1 @@
version=1.0-SNAPSHOT

0 comments on commit 14770b6

Please sign in to comment.