-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
I'd like to be able to set the excludeDevtools as a user property (for spring-boot-maven-plugin) on the command line when building my project in Maven :
mvn clean verify -Dspring-boot.excludeDevtools=false
Right now you have to add a configuration entry <excludeDevtools>false</excludeDevtools>
to your pom.xml. This is code that you don't want to end up in your production code. When you add it via the command line the pom is kept clean.
I tried to create a pull request, but ran into trouble with our corporate Nexus and snapshot/milestones. I think the fix is quite easy (but wasn't able to verify it).
How to implement the fix
In spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java#189 (the line before private boolean excludeDevtools = true; should be replaced with :
@Parameter(property = "spring-boot.excludeDevtools", defaultValue = "true")I think the docs are auto-generated, but when they're not the user property has to be added to it.
I kept the property name in line with ones used in the other exclude properties
It would be nice if it could also be backported to version 2.1.x
Verify the fix
To verify the fix works create a sample project on https://start.spring.io/ with all the default settings.
In pom.xml add
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
to the <dependencies> section.
Build the project with
mvn clean package -Dspring-boot.excludeDevtools=false
Run
jar tf target/demo-0.0.1-SNAPSHOT.jar | grep dev
and you should see an entry like BOOT-INF/lib/spring-boot-devtools-2.1.4.RELEASE.jar
Thanks!