Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANCHOR-533] Add Gradle tasks to start servers and run docker compose up #1206

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,33 @@ plugins {
jacoco
}

tasks {
register<Copy>("updateGitHook") {
from("scripts/pre-commit.sh") { rename { it.removeSuffix(".sh") } }
into(".git/hooks")
doLast {
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
project.exec { commandLine("chmod", "+x", ".git/hooks/pre-commit") }
}
// *******************************************************************************
// Task registration and configuration
// *******************************************************************************

// The printVersionName task is used to print the version name of the project. This
// is useful for CI/CD pipelines to get the version string of the project.
tasks.register("printVersionName") { println(rootProject.version.toString()) }

// The updateGitHook task is used to copy the pre-commit.sh file to the .git/hooks
// directory. This is part of the efforts to force the Java/Kotlin code to be formatted
// before committing the code.
tasks.register<Copy>("updateGitHook") {
from("scripts/pre-commit.sh") { rename { it.removeSuffix(".sh") } }
into(".git/hooks")
doLast {
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
project.exec { commandLine("chmod", "+x", ".git/hooks/pre-commit") }
}
}

"build" { dependsOn("updateGitHook") }
}

tasks { build { dependsOn("updateGitHook") } }

// *******************************************************************************
// Common configurations
// *******************************************************************************

subprojects {
apply(plugin = "java")
apply(plugin = "com.diffplug.spotless")
Expand All @@ -47,10 +60,12 @@ subprojects {
logger.warn("!!! WARNING !!!")
logger.warn("=================")
logger.warn(
" You are running Java version:[{}]. Spotless may not work well with JDK 17.",
javaVersion)
" You are running Java version:[{}]. Spotless may not work well with JDK 17.",
javaVersion
)
logger.warn(
" In IntelliJ, go to [File -> Build -> Execution, Build, Deployment -> Gradle] and check Gradle JVM")
" In IntelliJ, go to [File -> Build -> Execution, Build, Deployment -> Gradle] and check Gradle JVM"
)
}

if (javaVersion < "11") {
Expand Down Expand Up @@ -127,8 +142,9 @@ subprojects {
test {
useJUnitPlatform()
systemProperty(
"junit.jupiter.testclass.order.default",
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation")
"junit.jupiter.testclass.order.default",
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation"
)

exclude("**/AnchorPlatformCustodyEnd2EndTest**")
exclude("**/AnchorPlatformCustodyApiRpcEnd2EndTest**")
Expand Down Expand Up @@ -167,10 +183,9 @@ allprojects {
tasks.jar {
manifest {
attributes(
mapOf(
"Implementation-Title" to project.name, "Implementation-Version" to project.version))
mapOf("Implementation-Title" to project.name, "Implementation-Version" to project.version)
)
}
}
}

tasks.register("printVersionName") { println(rootProject.version.toString()) }
6 changes: 6 additions & 0 deletions docs/01 - Contributing/A - Development Environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ Run all tests: `./gradlew test`

Run subproject tests: `./gradlew :[subproject]:test`

### Running `docker-compose` up for development
`./gradlew dockerComposeUp`

### Starting all servers
`./gradlew startAllServers`

## Set up the Git Hooks

In order to have consistent code style, we use [Google Java Format](https://github.com/google/google-java-format) to
Expand Down
20 changes: 20 additions & 0 deletions service-runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,23 @@ tasks {
}

application { mainClass.set("org.stellar.anchor.platform.ServiceRunner") }

/**
* Start all the servers based on the `default` test configuration.
*/
tasks.register<JavaExec>("startAllServers") {
println("Starting all servers based on the `default` test configuration.")
group = "application"
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("org.stellar.anchor.platform.run_profiles.RunAllServers")
}

/**
* Run docker-compose up to start Postgres, Kafka, Zookeeper,etc.
*/
tasks.register<JavaExec>("dockerComposeUp") {
println("Running docker-compose up to start Postgres, Kafka, Zookeeper,etc.")
group = "application"
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("org.stellar.anchor.platform.run_profiles.RunDockerDevStack")
}
Loading