Skip to content

Commit

Permalink
Simplify micronaut dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-git committed Dec 11, 2024
1 parent cd0f363 commit c6ddfe5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
14 changes: 11 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[versions]
javamodularity-moduleplugin = '1.8.15'
sonarqube = '6.0.1.5171'
jacocolog = '3.1.0'
spotbugs = '6.0.26'
Expand All @@ -14,8 +13,9 @@ assertj = '3.26.3'
johnrengelman-shadow = '8.1.1'
io-micronaut = '4.4.4'

apiguardian-api = '1.1.2'

[plugins]
javamodularity-moduleplugin = { id = 'org.javamodularity.moduleplugin', version.ref = 'javamodularity-moduleplugin' }
sonarqube = { id = 'org.sonarqube', version.ref = 'sonarqube' }
jacocolog = { id = 'org.barfuin.gradle.jacocolog', version.ref = 'jacocolog' }
spotbugs = { id = 'com.github.spotbugs', version.ref = 'spotbugs' }
Expand All @@ -31,6 +31,7 @@ micronaut-aot = { id = 'io.micronaut.aot', version.ref = 'io-micronaut' }

[libraries]
jspecify = { module = 'org.jspecify:jspecify', version.ref = 'jspecify' }
slf4j-api = { module = 'org.slf4j:slf4j-api' }

junit = { module = 'org.junit:junit-bom', version.ref = 'junit' }
junit-jupiter = { module = 'org.junit.jupiter:junit-jupiter' }
Expand All @@ -39,7 +40,14 @@ junit-jupiter-engine = { module = 'org.junit.jupiter:junit-jupiter-engine' }
junit-platform-launcher = { module = 'org.junit.platform:junit-platform-launcher' }
assertj = { module = 'org.assertj:assertj-core', version.ref = 'assertj' }

jakarta-inject-api = { module = 'jakarta.inject:jakarta.inject-api' }
apiguardian-api = { module = 'org.apiguardian:apiguardian-api', version.ref = 'apiguardian-api' }
micronaut-core = { module = 'io.micronaut:micronaut-core' }
micronaut-test-core = { module = 'io.micronaut.test:micronaut-test-core' }
junit-platform-commons = { module = 'org.junit.platform:junit-platform-commons' }

[bundles]
test-implementation = ['junit-jupiter-api', 'assertj']
test-compile = ['junit-jupiter', 'junit-jupiter-engine']
test-runtime = ['junit-jupiter-engine', 'junit-platform-launcher']
test-runtime = ['junit-jupiter-engine', 'junit-platform-launcher']
test-micronaut-implementation = ['jakarta-inject-api', 'apiguardian-api', 'junit-platform-commons', 'micronaut-core', 'micronaut-test-core']
8 changes: 4 additions & 4 deletions mnt/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'java-library'
alias(libs.plugins.javamodularity.moduleplugin)
alias(libs.plugins.johnrengelman.shadow)
alias(libs.plugins.micronaut.application)
alias(libs.plugins.micronaut.library)
Expand All @@ -10,13 +9,15 @@ plugins {

dependencies {
implementation libs.jspecify
implementation 'org.yaml:snakeyaml'
compileOnly 'io.micronaut:micronaut-http-client'
runtimeOnly 'org.yaml:snakeyaml'
runtimeOnly 'io.micronaut.serde:micronaut-serde-jackson'
runtimeOnly 'ch.qos.logback:logback-classic'

implementation libs.slf4j.api

testImplementation(platform(libs.junit))
testImplementation libs.bundles.test.implementation
testImplementation libs.bundles.test.micronaut.implementation
testCompileOnly libs.bundles.test.compile
testRuntimeOnly libs.bundles.test.runtime
}
Expand All @@ -28,7 +29,6 @@ application {

micronaut {
importMicronautPlatform = true
runtime('netty')
testRuntime('junit5')
processing {
incremental(true)
Expand Down
8 changes: 4 additions & 4 deletions mnt/src/main/java/com/ak/micronaut/Application.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ak.micronaut;

import io.micronaut.context.ApplicationContext;
import io.micronaut.runtime.Micronaut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -12,8 +11,9 @@ private Application() {
}

public static void main(String[] args) {
ApplicationContext context = Micronaut.run(Application.class, args);
String appName = context.getEnvironment().get("micronaut.application.name", String.class).orElse("");
LOGGER.info("{} running = {}", appName, context.isRunning());
try (ApplicationContext context = ApplicationContext.run(args)) {
String appName = context.getEnvironment().get("micronaut.application.name", String.class).orElse("");
LOGGER.info("{} running = {}", appName, context.isRunning());
}
}
}
2 changes: 0 additions & 2 deletions mnt/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module com.ak.micronaut {
requires org.jspecify;
requires org.slf4j;
requires org.yaml.snakeyaml;
requires jakarta.inject;
requires jakarta.annotation;
requires io.micronaut.context;
requires io.micronaut.inject;
}
14 changes: 2 additions & 12 deletions mnt/src/test/java/com/ak/micronaut/ApplicationTest.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
package com.ak.micronaut;

import io.micronaut.context.ApplicationContext;
import io.micronaut.runtime.EmbeddedApplication;
import org.junit.jupiter.api.AfterAll;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;

@MicronautTest(startApplication = false, transactional = false)
class ApplicationTest {
private static final EmbeddedApplication<?> APPLICATION = ApplicationContext.run(EmbeddedApplication.class);

@AfterAll
static void tearDown() {
APPLICATION.stop();
}

@Test
void testItWorks() {
assertThat(APPLICATION.isRunning()).isTrue();
assertThatNoException().isThrownBy(() -> Application.main(new String[] {}));
}
}

0 comments on commit c6ddfe5

Please sign in to comment.