9

maven jar 플러그인을 사용하여 jar : bar-1.0.0.jar 및 bar-1.0.0-client.jar 두 개를 빌드합니다. 내 POM에서 실제로분류자를 사용하여 이슈에 대한 maven 종속성 변경

나는 다음과 같은 의존성이 있습니다

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

이 이슈

두 버전 줄-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 사용시 범위를 정의

-> 두 번째 (긴) 해결책 : '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> 

이 솔루션의 문제는 내 클라이언트 인터페이스 중에 컴파일 오류가 발생 일부 누락 된 인터페이스와 받는다는을 가지고 있다는 사실에 기인한다 컴파일 단계.

그리고 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

답변

관련 문제