Creating new projects with maven Archetypes

已回答

A growing frustration with me is this feature of "creating new Intellij projects with maven Archetypes".

I'm purposely quoting this since inevitably the selected archetype from the generated list will fail with "The desired archetype does not exist" errors...

If it doesn't exist, why is it being presented? I could give more details on which of the archetypes are failing, but ideally the entire list should be visited regularly to weed out and edit accordingly. Frankly not worth my time to report each and every archetype failure, but would seem like a basic bookkeeping chore from jet brains that can/should be automated.    

0

Sorry for the issue. Could be the https://youtrack.jetbrains.com/issue/IDEA-110617 If version is not found IDE uses RELEASE by default. What archetypeVersion is set when IDE generates the project? Could you specify the full command line (it is printed in the very first line in Run tool window). Thank you.

0

Not sure if this is what you were after, but...


"C:\Program Files\Java\jdk1.8.0_201\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\kkrasnowsky\AppData\Local\Temp\archetype1tmp -Xms256m -Xmx512m "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\lib\idea_rt.jar=51865:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version=2020.2.1 -DinteractiveMode=false -DgroupId=com.llts -DartifactId=JPATest -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=com.rfc.maven.archetypes -DarchetypeArtifactId=jpa-maven-archetype -DarchetypeVersion=RELEASE -DarchetypeRepository=http://maven.rodcoffin.com/repo org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repsoitory with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
Downloading from central: https://repo.maven.apache.org/maven2/com/rfc/maven/archetypes/jpa-maven-archetype/maven-metadata.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.195 s
[INFO] Finished at: 2020-09-10T13:06:46-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (com.rfc.maven.archetypes:jpa-maven-archetype:RELEASE) -> [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


wouldn't think I should have to augment my local mvn settings for this?

 

 

0

Thank you. IDE takes archetypes information from Maven repository archtype catalog. IDE loads archetypes from these Maven indexes including their repository URLs and versions. if version is omitted the RELEASE value is used. See https://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-catalog.html

Probably the IDE experience could be improved if there is outdated or invalid information in Maven index. Not sure at the moment though how would be better proceed here.

0

There is a IntelliJ Plugin:

to enable IntelliJ IDEA to fetch external Maven Archetype Catalog files.

Let's quote from the Plugin site:

IntelliJ IDEA is not able to fetch external Maven Archetype Catalog files (archetype-catalog.xml).
To use custom Maven Archetypes, you had to add external Maven Archetypes manually.

This plugin for IntelliJ IDEA allows you to define a list of external Maven Archetype Catalog files.
Those files are fetched and the containing Maven Archetypes are made available in IntelliJ IDEA when creating new Maven projects.

Usage

It adds a new entry Maven Archetype Catalogs to the Settings menu at

       File > Settings > Build, Execution and Deployment > Build tools.

Here you can

  • add additional URLs or
  • choose local files external archetype-catalog.xml files.

If you need to authenticate to the reposistory, use an URL like 'http://[username]:[password]@[url]'.

After adding those Catalog files the Archetypes present in these files will be available
when creating new Maven projects or Maven modules based on Archetypes.

0

I am the author of the Maven Archetype Catalogs plugin. If you have questions about it just tell me.

0

请先登录再写评论。