spring-projects / spring-projects/spring-modulith

archunit included in runtime classpath via spring-modulith-core even when not using spring-modulith-runtime

Open
#1,329 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

I'm encountering an unexpected issue where com.tngtech.archunit:archunit is included in my runtime classpath, even though I'm not using spring-modulith-runtime and I only depend on spring-modulith-starter-core.

Problem

I'm building a JavaFX application with Spring Boot and Spring Modulith. My build.gradle.kts includes:


implementation("org.springframework.modulith:spring-modulith-starter-core") 
implementation("org.springframework.modulith:spring-modulith-starter-jdbc")
// This is a local repo, patched to work with SQLite with Spring Data JDBC.
implementation("org.springframework.modulith:spring-modulith-events-jdbc:1.4.2-SNAPSHOT") 
testImplementation("org.springframework.modulith:spring-modulith-starter-test")
testImplementation("org.springframework.modulith:spring-modulith-docs")

However, ArchUnit ends up in the compiled application's classpath, which bloats the final artifact and is unused at runtime. I am using jpackage to bundle the app image, which adds the ArchUnit jar to the custom runtime it generates.

Investigation

Running

./gradlew dependencyInsight --dependency archunit --configuration runtimeClasspath

Yields

com.tngtech.archunit:archunit:1.4.1
\--- org.springframework.modulith:spring-modulith-core:1.4.1
     \--- org.springframework.modulith:spring-modulith-starter-core:1.4.1
          +--- runtimeClasspath (requested org.springframework.modulith:spring-modulith-starter-core)                                                                                                                                 
          \--- org.springframework.modulith:spring-modulith-starter-jdbc:1.4.1
               \--- runtimeClasspath (requested org.springframework.modulith:spring-modulith-starter-jdbc)  

This shows that spring-modulith-core, and spring-modulith-starter-jdbc includes ArchUnit directly in compile/runtime scope, even though ArchUnit is meant for architectural tests only.

Workaround

I'm currently excluding ArchUnit manually in my Gradle config from spring-modulith-starter-core and spring-modulith-starter-jdbc.

Apologies if this is actually an expected behaviour.

Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dependency path shown by Gradle's dependencyInsight command and inspect the module build configuration for spring-modulith-core and spring-modulith-starter-jdbc. Confirm that ArchUnit is absent from runtimeClasspath for applications using the core starters while remaining available where architectural tests require it.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.