9

maven jarプラグインでは、2つのjar:bar-1.0.0.jarとbar-1.0.0-client.jarを作成します。クラシファイアを使用してアーティファクトの依存関係を変更します

は、実は私のPOMに私は、次の依存関係を持っている:

<dependency> 
    <groupId>de.app.test</groupId> 
    <artifactId>foo</artifactId> 
    <version>1.0.0</version> 
</dependency> 

このアーティファクトは2つのバージョンバー-1.0.0.jarとバー-1.0.0-client.jarの

にも存在します私はbar-1.0.0-client.jarをfoo-1.0.0-client.jarに依存させ、bar-1.0.0.jarをfoo-1.0.0.jarに依存させたいと思っています。

================

- >最初の(間違った)溶液:提供される範囲を定義し、bar.jar

を使用するときに右fooパッケージを使用

- >第2(長い)解決策: 'サーバー'分類器を他のjarファイルに追加します。異なるプロファイルを使用してfoo成果物を構築し、分類子をプロパティに入れます。プロファイル溶液に関する

<dependency> 
    <groupId>de.app.test</groupId> 
    <artifactId>foo</artifactId> 
    <version>1.0.0</version> 
    <classifier>${profile.classifier}<classifier> 
</dependency> 

================

インタフェースモジュールポンポン

<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"> 
    <parent> 
     <groupId>com.app</groupId> 
     <artifactId>myapp-parent</artifactId> 
     <version>1.1.0</version> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.app</groupId> 
    <artifactId>myapp-interfaces</artifactId> 
    <version>1.1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <name>myapp Interfaces</name> 
    <profiles> 
     <profile> 
      <id>server</id> 
      <activation> 
       <activeByDefault>true</activeByDefault> 
      </activation> 
      <build> 
       <plugins> 
        <plugin> 
         <artifactId>maven-jar-plugin</artifactId> 
         <executions> 
          <execution> 
           <id>jar-server</id> 
           <phase>package</phase> 
           <goals> 
            <goal>jar</goal> 
           </goals> 
           <configuration> 
            <classifier>server</classifier> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
     <profile> 
      <id>client</id> 
      <activation> 
       <activeByDefault>true</activeByDefault> 
      </activation> 
      <build> 
       <plugins> 
        <plugin> 
         <artifactId>maven-jar-plugin</artifactId> 
         <executions> 
          <execution> 
           <id>jar-client</id> 
           <phase>package</phase> 
           <goals> 
            <goal>jar</goal> 
           </goals> 
           <configuration> 
            <classifier>client</classifier> 
            <excludes> 
             <exclude>**/server/**</exclude> 
            </excludes> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 
</project> 

実装モジュールポンポン

<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"> 
    <parent> 
     <groupId>com.app</groupId> 
     <artifactId>myapp-parent</artifactId> 
     <version>1.1.0-SNAPSHOT</version> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.app</groupId> 
    <artifactId>myapp-model</artifactId> 
    <version>1.1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <name>myapp Model</name> 
    <properties> 
     <myapp-interfaces.classifier></myapp-interfaces.classifier> 
     <myapp-interfaces.version>1.1.0-SNAPSHOT</myapp-interfaces.version> 

    </properties> 
    <dependencies> 
     <dependency> 
      <groupId>com.app</groupId> 
      <artifactId>myapp-interfaces</artifactId> 
      <version>${myapp-interfaces.version}</version> 
      <classifier>${myapp-interfaces.classifier}</classifier> 
     </dependency> 
     [...] 
    </dependencies> 
    <profiles> 
     <profile> 
      <id>server</id> 
      <build> 
       <plugins> 
        <plugin> 
         <artifactId>maven-jar-plugin</artifactId> 
         <executions> 
          <execution> 
           <id>jar-server</id> 
           <phase>package</phase> 
           <goals> 
            <goal>jar</goal> 
           </goals> 
           <configuration> 
            <classifier>server</classifier> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
      <dependencies> 
       <dependency> 
        <groupId>com.app</groupId> 
        <artifactId>myapp-interfaces</artifactId> 
        <version>${myapp-interfaces.version}</version> 
        <classifier>${myapp-interfaces.classifier}</classifier> 
       </dependency> 
      </dependencies> 
      <properties> 
       <myapp-interfaces.classifier>server</myapp-interfaces.classifier> 
      </properties> 
     </profile> 
     <profile> 
      <id>client</id> 
      <build> 
       <plugins> 
        <plugin> 
         <artifactId>maven-jar-plugin</artifactId> 
         <executions> 
          <execution> 
           <id>jar-client</id> 
           <phase>package</phase> 
           <goals> 
            <goal>jar</goal> 
           </goals> 
           <configuration> 
            <classifier>client</classifier> 
            <excludes> 
             <exclude>**/server/**</exclude> 
             <exclude>**/META-INF/services/**</exclude> 
            </excludes> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
      <properties> 
       <myapp-interfaces.classifier>client</myapp-interfaces.classifier> 
      </properties> 
      <dependencies> 
       <dependency> 
        <groupId>com.app</groupId> 
        <artifactId>myapp-interfaces</artifactId> 
        <version>${myapp-interfaces.version}</version> 
        <classifier>${myapp-interfaces.classifier}</classifier> 
       </dependency> 
      </dependencies> 
     </profile> 
    </profiles> 
</project> 

この解決策の問題は、私のクライアント・インタフェースが中にコンパイルエラーを投げるいくつか欠けているインタフェースとMavenを持っているという事実によるものですコンパイルフェーズ

私がmyapp-modelと他のプロジェクトを使用する場合、私は正しいmyapp-interfaceに依存しませんでした。

瓶を作り、特定のポンを入れることができるのだろうか?

+1

models.jar。だから何が問題なの? –

+0

実際には動作しませんでした。私のfoo-serverとfoo-clientでは、いくつかのインターフェースが削除されていないためです。私がプロジェクトをビルドすると、コンパイルエラーに直面します。この問題を説明するために質問を編集します。 – Vlagorce

+0

同じ問題についての古い質問[1]:http://www.mail-archive.com/[email protected]/msg102761.html – Vlagorce

答えて

関連する問題