If above solution doesn't work, then try below.
Due to maven-archetype-plugin version 3.2.1, pom file has 2.4.16 version for groovy-all
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.16</version>
<scope>compile</scope>
</dependency>
.m2/repository/org/apache/maven/archetype/archetype-common/3.2.1/archetype-common-3.2.1.pom: <version>2.4.16</version>
post-generate groovy using 2.4.8 version in below annotation. This is creating conflict and showing the error.
@grab(group="org.codehaus.groovy", module="groovy-all", version="2.4.8")
https://github.com/adobe/aem-project-archetype/blob/develop/src/main/resources/META-INF/archetype-po...
To resolve this issue using workaround, I updated 2.4.8 version in below POM under local .m2 repository. This might help someone in future
.m2/repository/org/apache/maven/archetype/archetype-common/3.2.1/archetype-common-3.2.1.pom
Refer thread: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/error-while-building-maven...