8

When I execute this:

 mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype \
-DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ \
-DarchetypeCatalog=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/archetype-catalog.xml

I got the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: archetypeCatalog 'http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/archetype-catalog.xml' is not supported anymore. Please read the plugin documentation for details. -> [Help 1]

And help1 looks like this:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

which hasn't been update for a long time.

First, I removed backslash and whitespace, obviously it didn't work. I thought it may be the parameter of archetypeCatalog, so I ran this:

mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeCatalog=remote -DarchetypeVersion=1.1.2-Beryllium-SR2

I got a error like this:

[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 (org.opendaylight.controller:opendaylight-startup-archetype:1.1.2-Beryllium-SR2) -> [Help 1]

The tutorial mentions that OpenDaylight maintains its own repositories outside of Maven Central, which means maven cannot resolve OpenDaylight artifacts by default. So I did as tutorial with following command:

cp -n ~/.m2/settings.xml{,.orig} ; \ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml

I even tried this:

cp -n ~/.m2/settings.xml{,.orig} ; \ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/stable/beryllium/settings.xml > ~/.m2/settings.xml

The settings.xml files just look the same. I have seen some similar issues these days. As a noob of both maven and opendaylight, I have no idea about what to do next step? I just want to generate an opendaylight arachetype to start a toaster.

Thank you for your help. Here is my maven inforamtion:

 ➜  ~ mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
ychz
  • 533
  • 2
  • 7
  • 15

6 Answers6

8

With maven-archetype-plugin 3.x it is not possible anymore to specify the repository as commandline argument (for consistency and security reasons).

So you have 2 options:

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
  • mvn org.apache.maven.plugins:maven-archetype-plugin:2.3:generate pins the version but did not fix for me. – TimP Feb 12 '18 at 23:22
2

As of Maven Archetype Plugin 3.0.0 the archetype resolution has changed. It is not possible anymore to specify the repository via the commandline, but instead the repositories as already specified for Maven are used. This means that also the mirrors and proxies are respected, as well as the authentication on repositories. 1.You would to delete -DarchetypeCatalog & -DarchetypeRepository 2. In your .m2/setting.xml, add

  <settings>
    <mirrors>
      <mirror>
        <id>mrm-maven-plugin</id>
        <name>Mock Repository Manager</name>
        <url>http://www.mycompany.com/maven-reporistory-manager</url>
        <mirrorOf>*,!archetype</mirrorOf>
      </mirror>
    </mirrors>

    <profiles>
      <profile>
      <id>acme</id>
      <repositories>
        <repository>
          <id>archetype</id>
          <url>https://www.acme.com/repo</url>
          <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>warn</checksumPolicy>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>acme</activeProfile>
  </activeProfiles>
</settings>
  1. Look at http://maven.apache.org/archetype/maven-archetype-plugin/archetype-repository.html
begginghard
  • 141
  • 1
  • 5
1

Add a repository whose id is archetype like this:

  <repository>
    <id>archetype</id>
    <url>https://repository.domain.com/path/to/repo/</url>
  </repository>

In my case,

  <repository>
     <id>archetype</id>
     <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
  </repository>

Basically, I executed without-DarchetypeRepository parameter, but put it in the settings.xml as above. And change -Darchetypecatalog parameter into remote or just set it empty. It works .

ychz
  • 533
  • 2
  • 7
  • 15
0

Recent Maven version doesn't support commandline definition for archetype. So, In short your default setting file should look like the following (vi ~/.m2/setting.xml),

<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=2 tabstop=2: -->
<!--
 Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.

 This program and the accompanying materials are made available under the
 terms of the Eclipse Public License v1.0 which accompanies this distribution,
 and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <id>opendaylight-release</id>
      <repositories>
        <repository>
          <id>opendaylight-mirror</id>
          <name>opendaylight-mirror</name>
          <url>https://nexus.opendaylight.org/content/repositories/public/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>opendaylight-mirror</id>
          <name>opendaylight-mirror</name>
          <url>https://nexus.opendaylight.org/content/repositories/public/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

    <profile>
      <id>opendaylight-snapshots</id>
      <repositories>
        <repository>
          <id>opendaylight-snapshot</id>
          <name>opendaylight-snapshot</name>
          <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
<repository>
     <id>archetype</id>
     <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
  </repository>

    </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>opendaylight-snapshot</id>
          <name>opendaylight-snapshot</name>
          <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
  </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>opendaylight-release</activeProfile>
    <activeProfile>opendaylight-snapshots</activeProfile>
  </activeProfiles>
</settings>
Learner
  • 425
  • 5
  • 14
0

If you are here because you got this error message while creating a Ninja project, just download the latest version of Maven.(anything > than 2.5.2).

This error occurred in Apache Maven versions less than 2.5.3

Ojonugwa Jude Ochalifu
  • 26,627
  • 26
  • 120
  • 132
0

Specify specific maven archtype plugin version (version less than 3.x) while generating project using archetype Catalog

mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeCatalog=<archetype-url>
Anil Agrawal
  • 2,748
  • 1
  • 24
  • 31