clean install
compiles the source code, runs the tests (unless disabled using -DskipTests
), packages the application, and installs to the local repository (a bunch of directories and files in the .m2
directory on your disk).
On the other hand clean package -Pbuild-image
runs clean package
with the build-image
profile. I assume you know the difference between package
and install
(otherwise, read this). This is where the difference ends from the Maven's perspective.
Maven knows nothing about any profile unless there is any functionality bound to it. Until then, the command is effectively equal to clean package
. Once you place a plugin execution under such a profile, then additional things start to happen depending on the configuration (what) and execution phase (when). Here is a sample profile build-image
with the plugin execution in the package
phase taken from https://piotrminkowski.com/2023/05/26/spring-boot-development-mode-with-testcontainers-and-docker/:
<profile>
<id>build-image</id>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<to>
<image>sample-spring-microservices-advanced/${project.artifactId}:${project.version}</image>
</to>
</configuration>
<executions>
<execution>
<goals>
<goal>dockerBuild</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>