Gradle automatic property expansion to pass parameters into Spring Boot not working in Eclipse

The application runs as expected when running as bootRun task in Eclipse IDE, but right clicking on project → Run As → Spring Boot App doesn’t replace the value of the property in the following prototype.

  1. build.gradle file

plugins {
	id 'org.springframework.boot' version '2.6.1'
	id 'io.spring.dependency-management' version '1.0.11.RELEASE'
	id 'java'
	id 'eclipse'

group = ''
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'

test {

// enable auto property expansion for passing gradle property to spring boot
processResources {
    duplicatesStrategy = 'include'
    with copySpec {
        from 'src/main/resources'
        include '**/application*.properties'
        include '**/application*.yaml'
        include '**/application*.yml' {
            prop ->
                if (prop.key != null) {
                    filter(ReplaceTokens, tokens: [(prop.key): prop.value.toString()])
                    filter(ReplaceTokens, tokens: [('project.' + prop.key): prop.value.toString()])
  1. Expansion Property!

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class DemoApplication implements CommandLineRunner {
	String expansionProperty;
	public static void main(String[] args) {, args);

	public void run(String... args) throws Exception {


The bootRun task results in expected output:

Hello Expansion Property!

4 actionable tasks: 4 executed

Running it as Spring Boot App in Eclipse results literal output without the value being replaced.

2021-12-04 21:49:35.598  INFO 27293 --- [           main]   : Started DemoApplication in 1.097 seconds (JVM running for 2.105)

I have also posted this issue in stackoverflow at java - How to pass gradle properties into Spring Boot and debug in Eclipse? - Stack Overflow

Why do you expect that property expansion is going to work when you specifically run the application in a way that bypasses the tool doing the property expansion?

Thanks for your prompt response. I currently have a workaround using Spring profile to pass hard-coded values running/debugging the app locally in Eclipse, but the intent here is to see how the great minds are overcoming this problem.