Archetype Error When Creating Policies

If you attempt to run Archetype from a directory with existing files when you create a policy, you might encounter a “Directory already exists” error. The error might differ based on the Maven version installed in your environment.

The following code snippet shows an error generated for maven-archetype-plugin version 3.1.1:

mvn -Parchetype-repository archetype:generate \
[INFO] Parameter: basedir, Value: C:\Users\32481\AnypointStudio\studio-workspace\mycustompolicy
[INFO] Parameter: package, Value: mule-policy
[INFO] Parameter: groupId, Value: 6344d2e6-eff9-4020-b792-719c463d5b92
[INFO] Parameter: artifactId, Value: ClientIdCustomPolicy
[INFO] Parameter: packageName, Value: mule-policy
[INFO] Parameter: version, Value: 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping mycustompolicy
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:14 min
[INFO] Finished at: 2019-07-03T14:07:26+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.1.1:generate (default-cli) on project mycustompolicy: Directory ClientIdCustomPolicy already exists - please run from a clean directory -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException.

Cause

This issue occurs because the directory in which Archetype is located already exists. The directory might have been created during a previous attempt to run Archetype.

Solution

To resolve this issue, delete the existing Archetype directory and run the command again.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub