Skip to content

Commit 8a08ee2

Browse files
Added Main class
1 parent d50e105 commit 8a08ee2

File tree

11 files changed

+200
-74
lines changed

11 files changed

+200
-74
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737

3838
- uses: docker/build-push-action@v5
3939
with:
40-
context: .
40+
context: ./app
4141
push: true
42-
cache-from: hexletcomponents/java-javalin-example:latest
42+
cache-from: irinakomarchenko/java-project-72:latest
4343
cache-to: type=inline
44-
tags: hexletcomponents/java-javalin-example:latest
44+
tags: irinakomarchenko/java-project-72:latest

.idea/compiler.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 77 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,50 @@
1-
/*
2-
* This file was generated by the Gradle 'init' task.
3-
*
4-
* This generated file contains a sample Java application project to get you started.
5-
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.8/userguide/building_java_projects.html in the Gradle documentation.
6-
*/
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
import org.gradle.api.tasks.testing.logging.TestLogEvent
73

84
plugins {
9-
// Apply the application plugin to add support for building a CLI application in Java.
105
application
6+
checkstyle
7+
id("io.freefair.lombok") version "8.13.1"
8+
id("com.github.ben-manes.versions") version "0.52.0"
9+
id("com.github.johnrengelman.shadow") version "8.1.1"
1110
}
1211

12+
application {
13+
mainClass.set("hexlet.code.App")
14+
}
15+
16+
group = "hexlet.code"
17+
version = "1.0-SNAPSHOT"
18+
1319
repositories {
14-
// Use Maven Central for resolving dependencies.
1520
mavenCentral()
1621
}
1722

1823
dependencies {
19-
// Use JUnit Jupiter for testing.
20-
testImplementation(libs.junit.jupiter)
21-
24+
implementation("com.h2database:h2:2.3.232")
25+
implementation("com.zaxxer:HikariCP:6.3.0")
26+
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.3")
27+
implementation("org.apache.commons:commons-text:1.13.1")
28+
implementation("gg.jte:jte:3.2.0")
29+
implementation("org.slf4j:slf4j-simple:2.0.17")
30+
implementation("io.javalin:javalin:6.6.0")
31+
//implementation("io.javalin:javalin-bundle:6.6.0")
32+
//implementation("io.javalin:javalin-rendering:6.6.0")
33+
34+
testImplementation("org.assertj:assertj-core:3.27.3")
35+
testImplementation(platform("org.junit:junit-bom:5.12.2"))
36+
testImplementation("org.junit.jupiter:junit-jupiter")
2237
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
23-
24-
// This dependency is used by the application.
25-
implementation(libs.guava)
26-
}
27-
28-
// Apply a specific Java toolchain to ease working on different environments.
29-
java {
30-
toolchain {
31-
languageVersion = JavaLanguageVersion.of(21)
32-
}
3338
}
3439

35-
application {
36-
// Define the main class for the application.
37-
mainClass = "hexlet.code.App"
38-
}
39-
40-
tasks.named<Test>("test") {
41-
// Use JUnit Platform for unit tests.
40+
tasks.test {
4241
useJUnitPlatform()
43-
}
42+
// https://technology.lastminute.com/junit5-kotlin-and-gradle-dsl/
43+
testLogging {
44+
exceptionFormat = TestExceptionFormat.FULL
45+
events = mutableSetOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED)
46+
// showStackTraces = true
47+
// showCauses = true
48+
showStandardStreams = true
49+
}
50+
}

app/settings.gradle.kts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
/*
2-
* This file was generated by the Gradle 'init' task.
3-
*
4-
* The settings file is used to specify which projects to include in your build.
5-
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.8/userguide/multi_project_builds.html in the Gradle documentation.
6-
*/
7-
8-
plugins {
9-
// Apply the foojay-resolver plugin to allow automatic download of JDKs
10-
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
11-
}
12-
13-
rootProject.name = "app"
14-
include("app")
1+
rootProject.name = "HexletJavalin"
Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
/*
2-
* This source file was generated by the Gradle 'init' task
3-
*/
4-
package hexlet.code;
5-
6-
public class App {
7-
public String getGreeting() {
8-
return "Hello World!";
9-
}
10-
11-
public static void main(String[] args) {
12-
System.out.println(new App().getGreeting());
13-
}
14-
}
1+
package hexlet.code;
2+
3+
import io.javalin.Javalin;
4+
import lombok.extern.slf4j.Slf4j;
5+
6+
@Slf4j
7+
public class App {public static Javalin getApp() {
8+
var app = Javalin.create(config -> {
9+
config.bundledPlugins.enableDevLogging();
10+
});
11+
12+
app.get("/", ctx -> {
13+
log.info("Processing request for /");
14+
ctx.result("Hello, World!");
15+
});
16+
17+
return app;
18+
}
19+
20+
public static void main(String[] args) {
21+
log.info("Launching the application Hexlet!");
22+
int port = Integer.parseInt(System.getenv().getOrDefault("PORT", "7070"));
23+
getApp().start(port);
24+
}
25+
}

0 commit comments

Comments
 (0)