blob: baa616857e94148c59b42c3f0526c7d61964a2e6 [file] [log] [blame]
buildscript {
dependencies {
// findBugs needs a newer version of Guava in the buildscript.
// otherwise it throws an exception
classpath "com.google.guava:guava:28.2-jre"
}
}
plugins {
id 'java'
id 'java-test-fixtures'
id 'application'
// since we're using a specific version here, we delay applying the plugin till the all projects
id "com.github.spotbugs" version "3.0.0" apply false
id 'org.hidetake.swagger.generator' version '2.16.0'
id "io.swagger.core.v3.swagger-gradle-plugin" version "2.1.2"
// 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'
}
allprojects {
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: "com.github.spotbugs"
repositories {
mavenCentral()
}
checkstyle {
toolVersion '7.8.1'
configFile file("${project.rootDir}/checkstyle.xml")
}
spotbugs {
toolVersion = '4.2.3'
excludeFilter = file("${project.rootDir}/spotbugs-exclude.xml")
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports.xml.enabled = false
reports.html.enabled = true
}
}
group 'org.apache.cassandra'
version project.version
sourceCompatibility = 1.8
// Take the application out once we're running via Cassandra
mainClassName = "org.apache.cassandra.sidecar.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"
applicationDefaultJvmArgs = ["-Dsidecar.logdir=./logs",
"-Dsidecar.config=" + confFile,
"-Dlogback.configurationFile=./conf/logback.xml",
"-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory",
"-javaagent:APP_HOME_TO_REPLACE/agents/jolokia-jvm-1.6.0-agent.jar=port=7777,host=localhost"]
startScripts {
doLast {
unixScript.text = unixScript.text.replace("APP_HOME_TO_REPLACE", "\${APP_HOME}")
}
}
run {
confFile = "file:" + File.separator + File.separator + "$projectDir/conf/sidecar.yaml"
jvmArgs = ["-Dsidecar.logdir=./logs",
"-Dsidecar.config=" + confFile,
"-Dlogback.configurationFile=./conf/logback.xml",
"-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory",
"-javaagent:$projectDir/agents/jolokia-jvm-1.6.0-agent.jar=port=7777,host=localhost"]
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration/java')
}
resources {
srcDirs = [main.resources, "src/integration/resources"]
}
}
}
configurations {
jolokia
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
implementation("io.vertx:vertx-web:${project.vertxVersion}")
implementation("io.vertx:vertx-dropwizard-metrics:${project.vertxVersion}")
implementation("io.vertx:vertx-web-client:${project.vertxVersion}")
implementation('com.datastax.cassandra:cassandra-driver-core:3.9.0+')
implementation('com.google.inject:guice:4.2.2')
implementation('io.swagger.core.v3:swagger-jaxrs2:2.1.0')
implementation("org.jboss.resteasy:resteasy-vertx:4.7.4.Final")
implementation(group: 'org.jboss.spec.javax.servlet', name: 'jboss-servlet-api_4.0_spec', version: '2.0.0.Final')
implementation('org.jetbrains:annotations:23.0.0')
// Trying to be exactly compatible with Cassandra's deps
implementation('org.slf4j:slf4j-api:1.7.25')
implementation('ch.qos.logback:logback-core:1.2.3')
implementation('ch.qos.logback:logback-classic:1.2.3')
implementation(group: 'org.apache.commons', name: 'commons-configuration2', version: '2.7')
implementation('org.webjars:swagger-ui:3.10.0')
runtime group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'
runtime group: 'org.yaml', name: 'snakeyaml', version: '1.26'
jolokia 'org.jolokia:jolokia-jvm:1.6.0:agent'
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${project.junitVersion}"
testImplementation "org.assertj:assertj-core:3.23.1"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}"
testImplementation('org.cassandraunit:cassandra-unit-shaded:3.11.2.0')
testImplementation('com.datastax.cassandra:cassandra-driver-core:3.9.0:tests')
testImplementation('org.mockito:mockito-all:1.10.19')
testImplementation("io.vertx:vertx-junit5:${project.vertxVersion}")
testImplementation(testFixtures(project(":common")))
implementation(project(":common"))
implementation(project(":cassandra40"))
testFixturesApi(testFixtures(project(":common")))
testFixturesImplementation("io.vertx:vertx-junit5:${project.vertxVersion}")
testFixturesImplementation('com.google.inject:guice:4.2.2')
testFixturesImplementation('org.mockito:mockito-all:1.10.19')
testFixturesImplementation("org.junit.jupiter:junit-jupiter-api:${project.junitVersion}")
testFixturesImplementation("org.junit.jupiter:junit-jupiter-params:${project.junitVersion}")
testFixturesImplementation("org.assertj:assertj-core:3.23.1")
testFixturesImplementation("io.vertx:vertx-web:${project.vertxVersion}")
}
task copyCodeStyle(type: Copy) {
from "ide/idea/codeStyleSettings.xml"
into ".idea"
}
// Lets copy the distributions from build/install directory to /bin and /lib
// directories to be aligned with C* distribution format
task copyDist(type: Copy) {
from "$buildDir/install/$applicationName"
into "$projectDir"
}
task copyJolokia(type: Copy) {
from configurations.jolokia
into "$projectDir/src/main/dist/agents"
}
// Lets clean distribution directories along with default build directories.
clean.doLast {
["agents", "bin", "conf", "lib"].each {
println "Deleting directory $projectDir/$it"
delete "$projectDir/$it"
}
println "Deleting generated docs $projectDir/src/main/resources/docs"
delete "$projectDir/src/main/resources/docs"
}
test {
// ordinarily we don't need integration tests
// see the integrationTest task
useJUnitPlatform()
reports {
junitXml.enabled = true
html.enabled = true
}
}
tasks.register("integrationTest", Test) {
jacoco {
enabled = false
}
useJUnitPlatform() {
includeTags "integrationTest"
}
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
shouldRunAfter test
}
// copy the user documentation to the final build
task copyDocs(type: Copy, dependsOn: ':docs:asciidoctor') {
from(tasks.getByPath(":docs:asciidoctor").outputs) {
include "**/*.html"
}
into "build/docs/"
exclude "tmp"
}
/**
* 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 ""
}
// This task is defined by swagger-gradle-plugin
// Resolves project openAPI specification and saves
// the result in JSON during the build process.
resolve {
outputFileName = 'api'
outputFormat = 'JSON'
prettyPrint = 'TRUE'
classpath = sourceSets.main.runtimeClasspath
resourcePackages = ['org.apache.cassandra.sidecar']
outputDir = file('build/generated/swagger')
}
// copyDist gets called on every build
copyDist.dependsOn installDist, copyJolokia
check.dependsOn checkstyleMain, checkstyleTest, integrationTest, jacocoTestReport
build.dependsOn copyDist, generateReDoc, generateSwaggerUI, copyJolokia, copyDocs
run.dependsOn build