I have been told to use mvn clean install -P base
at work for a particular task. I am trying to find what it exactly means.
According to https://maven.apache.org/archives/maven-1.x/reference/command-line.html , -P
lists all available plugins; and -p
is used to specify a project file (assuming pom).
But when I typed mvn -P
in my command line, I got an error saying:
Unable to parse command line options: Missing argument for option: P
usage: mvn [options] [<goal(s)>] [<phase(s)>]
What do the -P
and -p
stand for, and what are they used for exactly?
-U forces maven to check any external dependencies (third party dependencies) that might need to be updated based on your POM files. clean install are both basic maven lifecycle phases (https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html).
mvn clean: Cleans the project and removes all files generated by the previous build. mvn compile: Compiles source code of the project. mvn test-compile: Compiles the test source code.
mvn compile: This command is used to compile the project's source code. mvn clean: Here, the project is cleaned to remove all previous-build files generated. mvn test: With this command, one can run project testing steps. mvn test-compile: This command is used to compile the code from the test source.
To build a Maven project via the command line, you use the mvn command from the command line. The command must be executed in the directory which contains the relevant pom file. You pass the build life cycle, phase or goal as parameter to this command.
A reference tells us that -P
specifies which profile Maven is to run under. Projects can define multiple profiles which may pull in different dependencies, so this is required if you have a project that can do that.
The -p
flag isn't one I've run into in practice, nor does it really seem to exist in modern versions of Maven.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With