So, I suspect this is a feature request, sorry if it turns out to be a question but I don't see anything obvious in the documentation. I'm trying to use devtools in a test to read this file. I want to use devtools to read this file because we're using a monorepo, and it has secrets that need to be shared throughout the project. I was hoping to find some sort of alternate location optional parent search (should I open a request for this?) so I could put it in the root of the project. This however seemed reasonable.

plugins {
  alias(libs.plugins.kotlin)
  alias(libs.plugins.detekt)
  alias(libs.plugins.ktlint)
  alias(libs.plugins.spring.boot)
  `maven-publish`
}

dependencies {
  implementation(platform(libs.spring.platform))
  runtimeOnly(platform(libs.spring.platform))
  runtimeOnly(libs.spring.boot.starter.log4j2)
  implementation(libs.log4j.api)
  testImplementation(libs.bundles.test.api)
  testRuntimeOnly(libs.bundles.test.runtime)
  testRuntimeOnly(libs.spring.boot.devtools)
  developmentOnly(platform(libs.spring.platform))
  developmentOnly(libs.spring.boot.devtools)
  modules {
    module("org.springframework.boot:spring-boot-starter-logging") {
      replacedBy("org.springframework.boot:spring-boot-starter-log4j2")
    }
  }
}
@SpringBootTest
internal class BusinessDivisionRepositoryTest @Autowired constructor(
  private val businessDivisionRepository: BusinessDivisionRepository
) {

  @Test
  @WithMockUser("spring")
  fun findAllBy() {
    val divisions = businessDivisionRepository.findAllBy()

    assertThat(divisions).isNotEmpty
  }
}

I know it's not being read because the same test passes if I have it added in a profile under resources.

❯ fd gradle.lockfile -x grep devtools {} | awk -F'=' '{ print $1 }' | sort -u
org.springframework.boot:spring-boot-devtools:2.7.4

Comment From: wilkinsona

As described in the documentation to which you've linked, spring-boot-devtools.properties is intended to provide global, that is to say machine-wide, settings for a developer's preferred dev tools configuration. Given this intended usage, it's loaded from within the user's home directory and I don't think it makes sense to search for it in other locations.

The file's also only really intended for configuring dev tools so I wouldn't recommend trying to use if for other purposes. Furthermore, your use of the developmentOnly (which is the correct configuration for the dependency) means that it won't be on the classpath when you run your tests. As a result, the properties wouldn't be read even they were declared in the file beneath your home directory.

If you'd like some guidance on how to load the configuration that should be shared throughout your monorepo project, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

Comment From: xenoterracide

I put it in testRuntimeOnly too though. shouldn't it have loaded from that?

Comment From: xenoterracide

that seems like the bug, putting it in testRuntimeOnly should cause it to load when running a test.

Comment From: wilkinsona

The environment post-processor that loads the properties from within the home directory disables itself when it detects that it's running in a situation where Devtools should not be active such as during test execution.

Comment From: xenoterracide

and I'm somehow back to this same problem...

I know we don't love each other @wilkinsona , but please consider re-opening. The objective is for me to be able to access/use a developer private application.properties even during tests. Whether that's for personal settings, or something more important like credentials which I don't want accidentally committed to git. On the latter part, I would really love a way to have access to settings that were based on the application name.

Maybe this feature should be removed from devtools entirely, it doesn't feel like it belongs there. It should just be a part of spring boot's 12 factor configuration.

.config/spring-boot/spring-boot-devtools.properties
.config/spring-boot/application-{application-name}.properties