mavenmaven-scm

How to use basedir and workingDirectory parameters for scm:checkin goal in Maven?


I'm very new to Maven, and I'm confused about the purpose and correct usage of the basedir and workingDirectory parameters of the Maven SCM Plugin. Let's say I have the following file/folder structure (in Windows):

C:\fruits\
├───.git\
├───apples\
│   └───pom.xml
└───oranges\
    └───pom.xml

Before executing Maven (by invoking mvn.cmd from the command line), I change the current directory in shell to "C:\fruits\apples". Thus, in Maven's terms, "C:\fruits\apples" becomes the working directory with the appropriate pom.xml file to use for the apples project. On the other hand, in Git's terms, the working directory is "C:\fruits", because that's where the whole monorepo branch is checked out.

At some point during the build process, I use the Maven SCM Plugin to push some modifications. Currently, when specifying the scm:checkin goal, I provide --define workingDirectory="C:\fruits", but I'm not sure if this is the correct path here. Also, the plugin seems to work even though I currently don't define the basedir parameter at all, which is surprising, because the documentation lists basedir as the only required parameter. Unfortunately, the documentation doesn't explain the purpose of the basedir parameter (they just say it's "the base directory", duh), and doesn't explain which "working directory" (i.e., whether in Git's sense or in Maven's sense) the workingDirectory parameter is supposed to point at.

Could you please explain to me, exactly what paths should I define the basedir and workingDirectory parameters of the SCM plugin to point at (while Maven is working on my apples project) and why?


Solution

  • working directory parameter for SCM Plugin is in the context of Git i.e. the location of .git folder

    basedir is the directory for the location of pom.xml. Maven has many default properties and one of them is basedir.

    To find out more on how it is implemented, you can also check the code for this plugin from maven central or check ur local maven repo.