Error executing Maven archetype command to create Opendaylight project structure

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 updated in a long time.

First, I removed the backslash and spaces, obviously it didn't work. I thought it was the archetypeCatalog parameter, 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 the error:

[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 repos outside of Maven Central which means that maven cannot resolve OpenDaylight artifacts by default. So I did it as a tutorial with the 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 look the same. I've seen some similar problems these days. As a noob of both maven and opendaylight, I have no idea what to do next? I just want to create an opendaylight arachetype to start the toaster.

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

 ➜  ~ 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"

      

+5


source to share


5 answers


As of maven-archetype-plugin 3.x, it is no longer possible to specify the repository as a command line argument (for consistency and security reasons).

So you have 2 options:



+5


source


With Maven Archetype Plugin 3.0.0, the archetype change has changed. It is no longer possible to specify the repository via the command line, but instead the repositories are used as already stated for Maven. This means that mirrors and proxies are also taken into account, as well as authentication to repositories. 1.You remove -DarchatiDirectory and -DarshatireReposet 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. Have a look at http://maven.apache.org/archetype/maven-archetype-plugin/archetype-repository.html
+1


source


Add a repository whose ID is this archetype:

  <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 did it without DarchetypeRepository parameter, but put it in settings.xml as above. And change the -Darchetypecatalog parameter to remote or just set it blank. He works.

0


source


The latest version of Maven does not support command line definition for archetype. So in short, your default settings file should look like this (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>

      

0


source


If you are here because you got this error while building your project Ninja

, just download the latest Maven. (nothing> than 2.5.2).

This error occurred in Apache Maven versions less than 2.5.3

0


source







All Articles