0

Generating like this achieves the desired result -- generates using latest snapshot.

mvn archetype:generate ^
  --show-version ^
  --settings development-maven-settings.xml ^
  -Dmaven.wagon.http.ssl.insecure=true ^
  -DarchetypeCatalog=local ^
  -DarchetypeGroupId=dev.aherscu.qa ^
  -DarchetypeArtifactId=qa-testing-archetype ^
  -DarchetypeVersion=0.0.9-SNAPSHOT ^
  -DgroupId=com.acme ^
  -DartifactId=testing ^
  -Dversion=0.0.1-SNAPSHOT ^
  -Dpackage=com.acme.testing

The development-maven-settings.xml are as follows:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
          https://maven.apache.org/xsd/settings-1.0.0.xsd">

  <profiles>
    <profile>
      <id>sonatype-snapshots</id>
      <repositories>
        <repository>
          <id>archetype</id>
          <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>warn</checksumPolicy>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
</settings>

Replacing 0.0.9-SNAPSHOT with LATEST always resolves to 0.0.8. Anyway to make it run with latest snapshot?

Adrian Herscu
  • 738
  • 1
  • 6
  • 19
  • 1
    Please do not use `LATEST` as version because it's long time deprecated.. If you are using a SNPSHOT you could change your settings ` always` (see https://maven.apache.org/settings.html#repositories) or you could use `-U` option on command line... – khmarbaise Nov 26 '22 at 12:12

1 Answers1

-1

according to this: Archetype should always use latest version of dependency it is not possible to get the latest release like this, as the 'latest' will always resolve against your local repo, not the remote repo. So I think if you add the dependency as real <dependendcy> with <version>latest</version> to your prject and run the 'install' goal, the jar 0.0.9 jar should be installed to your local repo => now your 'latest' should fetch the real latest one.

roediGERhard
  • 163
  • 1
  • 12
  • "dependency" is irrelevant for generating a project from an archetype. – Adrian Herscu Nov 29 '22 at 18:38
  • I think you misunderstood my answer. You are using DarchetypeCatalog=local therefore your archetype comes from your local repository. As you may not have the current version of the archetype in your local repo it will not get the latest version from somewhere else. The dependency thing was just a suggestion for a workaround. The answer was the first sentence ;) – roediGERhard Nov 30 '22 at 09:14
  • but the archetype snapshot is in my local repo, it just takes the release version from central no matter what I tried :( – Adrian Herscu Dec 01 '22 at 10:24
  • huh. interesting. then i guess my answer was indeed not correct. – roediGERhard Dec 01 '22 at 10:27