使用maven-archetype-nar-exec生成项目

Mat*_*son 0 maven maven-archetype

我是Maven的新手.

如何创建maven-archetype-nar-exec项目类型?

如果我跑,mvn -archetype=generate我没有选择的选项maven-archetype-nar-exec

我是否必须将某些内容下载到Maven存储库中?

我正在使用 Maven 3.0.3

Ich*_*hyo 5

正如Sri Sankaran已经指出的那样,这些原型目前不包括在任何公共或官方资料库中.以下食谱为我工作

  1. 获得Archetypes的maven源项目.注意:每个Archetype都有一个单独的项目.在这里,我将以archetype-nar-exec为例进行说明

    git clone https://github.com/duns/maven-archetype-nar-exec.git
    
    Run Code Online (Sandbox Code Playgroud)
  2. 构建并将原型安装到本地存储库中

    cd maven-archetype-nar-exec
    mvn clean install
    
    Run Code Online (Sandbox Code Playgroud)
  3. 创建一个仅供现在使用的本地原型目录

    Example file: localCatalog.xml
    
    <archetype-catalog  xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd">
    <archetypes>
        <archetype>
            <groupId>org.apache.maven.archetypes</groupId>
            <artifactId>maven-archetype-nar-exec</artifactId>
            <version>1.0-SNAPSHOT</version>
            <repository>snapshots</repository>
            <description>Maven project to build a simple C/C++ executable</description>
        </archetype>
    
        <!-- ... add here further archetypes if you like -->
    
       </archetypes>
    </archetype-catalog>
    
    Run Code Online (Sandbox Code Playgroud)

    可能您需要调整版本和存储库ID(或URL)以指向本地存储库

  4. 调用maven archetype-plugin并将其指向我们的本地目录文件:

    mvn archetype:generate -DarchetypeCatalog=file://./localCatalog.xml
    
    Run Code Online (Sandbox Code Playgroud)

    其余的应该互动