Skip to content

Commit

Permalink
Add Scala/Gradle starter
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-brm committed Dec 3, 2024
1 parent 32d8071 commit d9bbb99
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/main/resources/templates/build.gradle.kts.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ plugins {
<#else>
kotlin ("jvm") version "1.7.21"
</#if>
<#elseif language == "scala">
scala
<#else>
java
</#if>
Expand Down Expand Up @@ -71,11 +73,18 @@ dependencies {
</#list>
<#if language == "kotlin" && vertxVersion?starts_with("4.")>
implementation(kotlin("stdlib-jdk8"))
<#elseif language == "scala">
implementation("org.scala-lang:scala3-library_3:3.5.2")
implementation("io.vertx:vertx-lang-scala_3:${vertxVersion}")
</#if>
<#if hasPgClient>
implementation("com.ongres.scram:client:2.1")
</#if>
<#if hasVertxJUnit5>
<#if language == "scala">
testImplementation("io.vertx:vertx-lang-scala-test_3:${vertxVersion}")
testImplementation("org.scalatest:scalatest_3:3.2.19")
testRuntimeOnly("org.scalatestplus:junit-5-11_3:3.2.19.0")
<#elseif hasVertxJUnit5>
testImplementation("io.vertx:vertx-junit5")
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")
<#elseif hasVertxUnit>
Expand Down Expand Up @@ -111,7 +120,9 @@ tasks.withType<ShadowJar> {
}

tasks.withType<Test> {
<#if hasVertxJUnit5>
<#if language == "scala">
useJUnitPlatform()
<#elseif hasVertxJUnit5>
useJUnitPlatform()
<#elseif hasVertxUnit>
useJUnit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ class HttpVerticle extends ScalaVerticle:
.putHeader("content-type", "text/plain")
.end("Hello from Vert.x!"))
.listen(8888)
.onSuccess(_ => println("HTTP server started on port 8888"))
.mapEmpty[Unit]()
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.scalatest.matchers.should.Matchers
import scala.language.implicitConversions


class MainVerticleSpec extends VerticleTesting[HttpVerticle], Matchers:
class TestMainVerticle extends VerticleTesting[HttpVerticle], Matchers:

"HttpVerticle" should "bind to 8888 and answer with 'Hello from Vert.x!'" in {
val httpClient = vertx.createHttpClient()
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/vertx/starter/service/GeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private void verifyMavenFiles() {

private void verifyMavenOutputFiles() throws IOException {
try (Stream<Path> pathStream = Files.walk(workdir)) {
Optional<Path> testResult = pathStream.filter(p -> p.toString().endsWith("TestMainVerticle.txt")).findFirst();
Optional<Path> testResult = pathStream.filter(p -> p.toString().endsWith("TestMainVerticle.xml")).findFirst();
assertThat(testResult).isPresent().hasValueSatisfying(p -> assertThat(p).isRegularFile());
assertThat(workdir.resolve("target/demo-1.0.0-SNAPSHOT-fat.jar")).isRegularFile();
}
Expand Down

0 comments on commit d9bbb99

Please sign in to comment.