Cannot build a project using maven archetype installed locally

1.2k views Asked by At

I am trying to test an unreleased version of a maven Archetype (24-SNAPSHOT) on my local/computer.

Archetype sources:

  • Using this project https://github.com/adobe/aem-project-archetype , downloaded the sources
  • Ran this command mvn install
    • Also tried mvn install archetype:update-local-catalog
  • The build was successful and i can also see the jar files copied to .m2 directory.
[INFO] Installing /Users/s/Projects/aem-project-archetype-master/target/aem-project-archetype-24-SNAPSHOT.jar to /Users/s/.m2/repository/com/adobe/aem/aem-project-archetype/24-SNAPSHOT/aem-project-archetype-24-SNAPSHOT.jar
[INFO] Installing /Users/s/Projects/research/AEM/aem-project-archetype-master/pom.xml to /Users/s/.m2/repository/com/adobe/aem/aem-project-archetype/24-SNAPSHOT/aem-project-archetype-24-SNAPSHOT.pom

Can see it when using mvn archetype:crawl

...
[INFO] Scanning /Users/s/.m2/repository/com/adobe/aem/aem-project-archetype/24-SNAPSHOT/aem-project-archetype-24-SNAPSHOT.jar
[INFO]  Archetype [com.adobe.aem:aem-project-archetype:24-SNAPSHOT] defined by repository path

When trying to create a new project but wanted to use the above built local archetype file.. using below command (with or without -DarchetypeCatalog=local)

mvn -B archetype:generate -D archetypeGroupId=com.adobe.granite.archetypes -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=24-SNAPSHOT -D aemVersion=6.5.0 -D appTitle="Demo Site" -D appId="demosite" -D groupId="com.demo.site" -D frontendModule=general -D includeExamples=y -DarchetypeCatalog=local

Shows this error message with "Build Failure":

...
[INFO] Generating project in Batch mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repository with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
[WARNING] The POM for com.adobe.granite.archetypes:aem-project-archetype:jar:24-SNAPSHOT is missing, no dependency information available

I have not added anything to .m2/settings.xml. What am i missing?

1

There are 1 answers

0
Suren Konathala On

After carefully looking at the commands being used, found the issue and solution.

The public path for the Archetype is: com.adobe.granite.archetypes by looking at the suggested command to use for published archetypes:

-D archetypeGroupId=com.adobe.granite.archetypes

while a local build is adding the Archetype in /.m2/repository/com/adobe/aem/ and not at /.m2/repository/com/adobe/granite/archetypes

The scan mvn archetype:crawl also shows the path as:

[INFO] Scanning /Users/s/.m2/repository/com/adobe/aem/aem-project-archetype/24-SNAPSHOT/aem-project-archetype-24-SNAPSHOT.jar

So a change in the command using (-D archetypeGroupId=com.adobe.aem) helped solve the issue:

Complete command:

mvn -B archetype:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=24-SNAPSHOT -D aemVersion=6.5.0 -D appTitle="Demo Site" -D appId="demosite" -D groupId="com.demo.site" -D frontendModule=general -D includeExamples=y -DarchetypeCatalog=local