Why am I getting cannot overwrite directory error while trying to do mvn package install?

69 Views Asked by At

I am using below command in windows 11, using git bash.

mvn install package -DskipTests -Pbin-dist -Drat.numUnapprovedLicenses=1000 -Dcheckstyle.skip -rf :pinot-distribution

Here is pom.xml

I am getting following error. Can someone please help?

[INFO] --- maven-assembly-plugin:3.1.1:single (binary-release-assembly-pinot) @ pinot-distribution ---
[INFO] Reading assembly descriptor: pinot-assembly.xml
[INFO] Building tar: C:\GitHubProjects\pinot\pinot-distribution\target\apache-pinot-1.1.0-SNAPSHOT-bin.tar.gz
[INFO] Copying files to C:\GitHubProjects\pinot\pinot-distribution\target\apache-pinot-1.1.0-SNAPSHOT-bin
[WARNING] Assembly file: C:\GitHubProjects\pinot\pinot-distribution\target\apache-pinot-1.1.0-SNAPSHOT-bin is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:exec (create-build-directory) @ pinot-distribution ---
/usr/bin/ln: 'C:\GitHubProjects\pinot\pinot-distribution/../build/apache-pinot-1.1.0-SNAPSHOT-bin': cannot overwrite directory
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:764)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:711)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:289)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

1

There are 1 best solutions below

2
Andrés S. Sanguino On

First of all, according to the POM you attached, it is composed of a bunch of modules, and the one where the problem is, seems to be the pinot-distribution one, and this is its POM:

<module>pinot-distribution</module>

The [WARNING]

As it can be seen in the logs you put, the execution that fails is binary-release-assembly-pinot. Guess that you are trying to create an assembly with the maven-assembly-plugin plugin, whose description is depicted in the pinot-assembly.xml file.

The problem I see here (the XML file) is that you are trying to create several assemblies:

  <formats>
    <format>tar.gz</format>
    <format>dir</format>
  </formats>

And the second one is suspicious (seems that the idea is just create a tar.gz file).

Above this snippet you can see another usage of this maven-assembly-plugin plugin, named as source-release-assembly-pinot, whose assembly descriptor file is pinot-source-assembly.xml, and looks like well formed.

The [ERROR]

After that, going back to the pinot-distribution POM, there is another execution, with id create-build-directory, where you are trying to create a symbolic link (command ln -sfn), within the directory

${project.basedir}/../build

So you have to consider where this directory is created / used, or maybe just not forcing it (-f), because it involves overwriting it.