Skip to content

Improve documentation when to add the Spring Modulith Core artifact in compile scope #943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hyeonseokhan opened this issue Nov 19, 2024 · 2 comments
Assignees
Labels
in: core Core module meta model in: reference documentation Our own reference documentation type: improvement Minor improvements
Milestone

Comments

@hyeonseokhan
Copy link

I want to implement ApplicationModuleDetectionStrategy to change the base package. However, I am encountering a compilation error as shown below and am looking for a solution.

image

and gradle setting

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.3.5'
    id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com.toyproject'
version = '0.0.1'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

ext {
    set('springModulithVersion', "1.2.4")
}


dependencies {
    implementation fileTree(dir: "./libs", includes: ["*.jar"])
    implementation 'com.google.code.gson:gson:2.11.0'
    implementation 'commons-codec:commons-codec:1.17.1'

    // Spring Web
    implementation 'org.springframework.boot:spring-boot-starter-web'

    implementation 'org.springframework.boot:spring-boot-starter-aop'

    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'

    implementation 'org.springframework.boot:spring-boot-starter-validation'

    // Spring Modulith
    implementation 'org.springframework.modulith:spring-modulith-starter-core'

    implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    implementation 'com.zaxxer:HikariCP:5.0.1'
    implementation 'com.h2database:h2:2.2.220'

    implementation 'org.web3j:core:4.12.1'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.modulith:spring-modulith-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.modulith:spring-modulith-bom:${springModulithVersion}"
    }
}

tasks.named('test') {
    useJUnitPlatform()
}

image

@odrotbohm odrotbohm added in: core Core module meta model in: reference documentation Our own reference documentation type: improvement Minor improvements labels Nov 19, 2024
@odrotbohm
Copy link
Member

ApplicationModuleDetectionStrategy is contained in the spring-modulith-core artifact, which is only imported in runtime scope by spring-modulith-starter-core (as documented here). If you want to customize your module setup, you additionally need to declare spring-modulith-core as a compile scope dependency.

I'll make sure we add a corresponding note to the relevant sections of the reference documentation.

@odrotbohm odrotbohm added this to the 1.4 M1 milestone Nov 26, 2024
@ciberkleid ciberkleid changed the title I cannot declare classes under 'org.springframework.modulith.core' Compile-time support for 'org.springframework.modulith.core' Dec 11, 2024
ciberkleid added a commit that referenced this issue Dec 11, 2024
@ciberkleid
Copy link
Contributor

ciberkleid commented Dec 11, 2024

Docs have been updated to say that:

  • If you are customizing ApplicationModuleDetectionStrategy for module verification or documentation, you should place the code (and corresponding application.properties registration) in your application's test sources as spring-modulith-core is included under test scope by spring-modulith-starter-test
  • Otherwise, if your customization is for runtime purposes, you need to explicitly declare spring-modulith-core as a compile-time dependency.

@odrotbohm odrotbohm changed the title Compile-time support for 'org.springframework.modulith.core' Improve documentation when to add the Spring Modulith Core artifact in compile scope Dec 11, 2024
odrotbohm pushed a commit that referenced this issue Dec 11, 2024
odrotbohm pushed a commit that referenced this issue Dec 11, 2024
odrotbohm added a commit that referenced this issue Dec 11, 2024
Slight rewording of the section talking about the usage of application module detection strategies with runtime components. Added notes in both the runtime support and production ready features chapters to point to the new instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Core module meta model in: reference documentation Our own reference documentation type: improvement Minor improvements
Projects
None yet
Development

No branches or pull requests

3 participants