Skip to content

Commit d9bbb99

Browse files
committed
Add Scala/Gradle starter
1 parent 32d8071 commit d9bbb99

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/main/resources/templates/build.gradle.kts.ftl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ plugins {
1717
<#else>
1818
kotlin ("jvm") version "1.7.21"
1919
</#if>
20+
<#elseif language == "scala">
21+
scala
2022
<#else>
2123
java
2224
</#if>
@@ -71,11 +73,18 @@ dependencies {
7173
</#list>
7274
<#if language == "kotlin" && vertxVersion?starts_with("4.")>
7375
implementation(kotlin("stdlib-jdk8"))
76+
<#elseif language == "scala">
77+
implementation("org.scala-lang:scala3-library_3:3.5.2")
78+
implementation("io.vertx:vertx-lang-scala_3:${vertxVersion}")
7479
</#if>
7580
<#if hasPgClient>
7681
implementation("com.ongres.scram:client:2.1")
7782
</#if>
78-
<#if hasVertxJUnit5>
83+
<#if language == "scala">
84+
testImplementation("io.vertx:vertx-lang-scala-test_3:${vertxVersion}")
85+
testImplementation("org.scalatest:scalatest_3:3.2.19")
86+
testRuntimeOnly("org.scalatestplus:junit-5-11_3:3.2.19.0")
87+
<#elseif hasVertxJUnit5>
7988
testImplementation("io.vertx:vertx-junit5")
8089
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")
8190
<#elseif hasVertxUnit>
@@ -111,7 +120,9 @@ tasks.withType<ShadowJar> {
111120
}
112121

113122
tasks.withType<Test> {
114-
<#if hasVertxJUnit5>
123+
<#if language == "scala">
124+
useJUnitPlatform()
125+
<#elseif hasVertxJUnit5>
115126
useJUnitPlatform()
116127
<#elseif hasVertxUnit>
117128
useJUnit()

src/main/resources/templates/src/main/scala/MainVerticle.scala.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ class HttpVerticle extends ScalaVerticle:
2525
.putHeader("content-type", "text/plain")
2626
.end("Hello from Vert.x!"))
2727
.listen(8888)
28+
.onSuccess(_ => println("HTTP server started on port 8888"))
2829
.mapEmpty[Unit]()

src/main/resources/templates/src/test/scala/TestMainVerticle.scala.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.scalatest.matchers.should.Matchers
1010
import scala.language.implicitConversions
1111

1212

13-
class MainVerticleSpec extends VerticleTesting[HttpVerticle], Matchers:
13+
class TestMainVerticle extends VerticleTesting[HttpVerticle], Matchers:
1414

1515
"HttpVerticle" should "bind to 8888 and answer with 'Hello from Vert.x!'" in {
1616
val httpClient = vertx.createHttpClient()

src/test/java/io/vertx/starter/service/GeneratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private void verifyMavenFiles() {
292292

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

0 commit comments

Comments
 (0)