[Mavenの]カスタム原型

原型通常のプロジェクトは、基本的なテンプレートがあり、あなたが直接、テンプレートベースのプロジェクトをビルドすることができれば、足場に相当し、

1.新しいMavenプロジェクトを作成し、プロジェクトのpom.xmlを定義します

< プロジェクトのxmlns = "http://maven.apache.org/POM/4.0.0" のxmlns:XSI = "http://www.w3.org/2001/XMLSchema-instance" 
         のxsi:schemaLocationの= "のhttp:/ /maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd」> 
    < modelVersion > 4.0.0 </ modelVersion > 

    < groupIdを> com.ppdai。 cbd.ddp </ groupIdを> 
    < たartifactId > flinkCustomArchitype </ たartifactId > 
    < バージョン> 1.0-SNAPSHOT </ バージョン> 
    <パッケージ>のmaven-原型</ 梱包> 

    < 構築> 
        < 拡張子> 
            < 拡張子> 
                < groupIdを> org.apache.maven.archetype </ groupIdを> 
                < たartifactId >原型包装</ たartifactId > 
                < バージョン> 3.1.1 </ バージョン> 
            </ 拡張> 
        </ エクステンション> 
    </ 構築> 
</ プロジェクト>

2.原型記述ファイル、ファイルのディレクトリ(プロジェクトのルートディレクトリ)flinkCustomArchitype / srcに/メイン/リソース/ META-INF / Mavenを作成します。

< 原型・ディスクリプタ
         にxsi:schemaLocationの= "http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 
        http://maven.apache.org/xsd/archetype-descriptor- 1.0.0.xsd " 
        のxmlns = "http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" 
        のxmlns:XSI =" http://www.w3.org/ 2001 / XMLスキーマ・インスタンス」
        名前= "flinkCustomArchitype" > 
    < ファイルセット> 
        < ファイルセット濾過= "true"をパッケージ化= "真" > 
            < ディレクトリ>SRC /メイン/ javaの</ ディレクトリ>
        </ ファイルセット> 
    </ ファイルセット> 
</ 原型-記述子>

3.ディレクトリ構造 

原型
| -のpom.xml 
` - SRC 
    ` -メイン
        ` -リソース
            | - META-INF 
            | ` -達人
            | `--archetype-のmetadata.xml 
            ` -原型資源
                | -のpom.xml(プロトタイプのpom.xml 
                ` - SRC 
                    | -メイン
                    | ` - javaの
                    | ` - App.java 
                    ` -テスト
                        ` - Javaの
                            ` - AppTest.java

4.作成し  たプロトタイプのpom.xmlを

< プロジェクトのxmlns = "http://maven.apache.org/POM/4.0.0" のxmlns:XSI = "http://www.w3.org/2001/XMLSchema-instance" 
    のxsi:schemaLocationの= "のhttp:/ /maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd」> 
    < modelVersion > 4.0.0 </ modelVersion > 
 
    < groupIdを> $ {}のgroupId </ のgroupId > 
    < たartifactId > $ {たartifactId} </ たartifactId > 
    < バージョン> $ {バージョン} </ バージョン>
    < パッケージ> JAR </ パッケージ> 
 
    < 名前> $ {たartifactId} </ 名前> 
    < URL > http://www.myorganization.org </ URL > 
 
    < 依存性> 
        < 依存> 
                < groupIdを> JUnitの</ groupIdを> 
                < たartifactId > JUnitの</ たartifactId > 
                 < バージョン> 4.12 </ バージョン> 
                < スコープ>テスト</ スコープ> 
        </ 依存関係> 
    </ 依存関係> 
</ プロジェクト>

5. MVNローカルインストールをインストール

6. CD空のディレクトリ、実行

MVNの原型:生成\ 
  -DarchetypeGroupId = < 原型-のgroupId >                 \ 
  -DarchetypeArtifactId = < 原型-たartifactId >           \ 
  -DarchetypeVersion = < 原型バージョン>                 \ 
  -DgroupId = < my.groupid >                                 \ 
  -DartifactId = < 私の-たartifactId >

終わり。そして、記事に水を

おすすめ

転載: www.cnblogs.com/zhengwangzw/p/11545359.html