Alessandro Scarozza
Alessandro Scarozza

Reputation: 4438

why i need to run clean manually before build?

this is my configuration

application.yml

spring:
    profiles.active: ${env}

build.gradle

processResources {
    expand(project.properties)
}

if I run this all works fine

gradle clean build -Penv=a
gradle clean build -Penv=b

but if I run this, "env" prop remain on first configuration

gradle build -Penv=a
gradle build -Penv=b

the strange is if i put clean { println "CLEAN" } i see that clean is called every time with all 4 commands

Upvotes: 1

Views: 426

Answers (1)

lance-java
lance-java

Reputation: 28061

Gradle uses each task's inputs and outputs to perform an up to date check. If the inputs & outputs haven't changed since the last run it can be skipped. You'll need to add the 'env' as a task input so it's considered in the up to date check.

Eg:

processResources {
    inputs.properties(project.properties)
    expand(project.properties)
}

See up to date checks

Upvotes: 1

Related Questions