1

ビルドで自分のファイルと並行してファイルpom.xmlを生成するために、自分で maven-war-plugin を使用しています。私のビルドは、ターゲット ディレクトリにファイルを作成しています。そして、ファイルのみがローカルリポジトリにインストールされます。作成されたファイルもローカル リポジトリにプッシュする方法はありますか。以下は私のpom.xmlのスニペットですjarwarjava web projectmavenwarjarwarjar

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>             
        <archive>
            <addMavenDescriptor>false</addMavenDescriptor>
            </archive>
            <archiveClasses>true</archiveClasses>
        <packagingExcludes>WEB-INF/lib/x*.jar</packagingExcludes>
        <webXml>${project.basedir}\src\main\webapp\WEB-INF\web.xml</webXml>
         <webResources>
        <resource>
          <directory>${project.basedir}\src\main\webapp</directory>
          <includes>
            <include>**/*.*</include>
          </includes>
        </resource>
            </webResources>
    </configuration>
</plugin>

前もって感謝します!

pom.xml コンテンツ:

<project 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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.xyz</groupId>
    <artifactId>x</artifactId>
    <packaging>war</packaging>
    <version>1.0.0-SNAPSHOT</version>
    <name>x</name>
    <url>http://maven.apache.org</url>
    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>             
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        </archive>
                        <archiveClasses>true</archiveClasses>
                    <packagingExcludes>WEB-INF/lib/x*.jar</packagingExcludes>
                    <webXml>${project.basedir}\src\main\webapp\WEB-INF\web.xml</webXml>
                     <webResources>
                    <resource>
                      <directory>${project.basedir}\src\main\webapp</directory>
                      <includes>
                        <include>**/*.*</include>
                      </includes>
                    </resource>
                        </webResources>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
              <groupId>com.googlecode.addjars-maven-plugin</groupId>
              <artifactId>addjars-maven-plugin</artifactId>
              <version>1.0.2</version>
              <executions>
                <execution>
                    <goals>
                        <goal>add-jars</goal>
                    </goals>
                    <configuration>
                        <resources>
                            <resource>
                                <directory>${project.basedir}/src/main/webapp/WEB-INF/lib</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
              </executions>
            </plugin>

        </plugins>
    </build>
</project>
4

1 に答える 1

1

これは maven の正しい使用方法ではありません。Maven はモジュール性がすべてであり、結果として「1 つのプロジェクトと 1 つのアーティファクト」というルール (または推奨事項) があります。納得できない場合は、このブログも参照してください: 1 つのプロジェクトから 2 つの JAR を作成する方法 (…そしてなぜそうすべきでないのか) . 複数のjarについてですが、コンセプトは同じです。

他の人がそれを依存関係として使用している間、jar 用に 1 つの個別のプロジェクトを持つように作業を再構築する必要があると思います。

于 2014-11-04T12:46:34.913 に答える