Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn archetype:generate which version selected

According to doc , there is no default value for <archetypeVersion>.

So, when I do mvn archetype:generate , and I select an archetype , then it might be possible that many versions of it might exist in repository. Which will be selected ?

Example :

In the repository - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/archetype-catalog.xml , there are basically 2 archetypes with 2 versions each.

like image 675
Number945 Avatar asked Feb 02 '26 13:02

Number945


1 Answers

In your meta-data you should be able to specify a release version, here is the example from quickstart:

cat /cygdrive/c/Users/G01103266/.m2/repository/org/apache/maven/archetypes/maven-archetype-quickstart/maven-metadata-central.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>org.apache.maven.archetypes</groupId>
  <artifactId>maven-archetype-quickstart</artifactId>
  <versioning>
    <latest>1.4</latest>
    <release>1.4</release>
    <versions>
      <version>1.0-alpha-1</version>
      <version>1.0-alpha-2</version>
      <version>1.0-alpha-3</version>
      <version>1.0-alpha-4</version>
      <version>1.0</version>
      <version>1.1</version>
      <version>1.3</version>
      <version>1.4</version>
    </versions>
    <lastUpdated>20181213005348</lastUpdated>
  </versioning>
</metadata>

In your local repository or Nexus/Artifactory you may have an archetype-catalog.xml this will define the allowed versions, for you to choose from, here is the one for Maven Central.

If there is no mention of the archetype in the catalog the version will default to 1.0.

If there is more than one version it will ask you to pick a version and default to release.

I create test projects with the following script

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=RELEASE

Will use version 1.4

like image 53
Essex Boy Avatar answered Feb 04 '26 04:02

Essex Boy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!