2017-01-12 11 views
0

원격 저장소에서 jar 파일을 가져 와서 로컬 저장소에 추가하려고하는 maven 프로젝트가 있습니다. 그 클래스를 참조하는 대신에 추가 한 후에 현재 프로젝트의 입력으로 사용되는 jar 파일을 실행해야합니다.현재 프로젝트를 실행하기 전에 maven에서 종속성 jar를 실행하는 방법

제가 시도했지만 빌드 문제는 없지만 여전히 종속성을 실행하는 것은 아닙니다.

내 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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>secmaven</groupId> 
    <artifactId>secmaven</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>secmaven</name> 
    <description>secmaven</description> 

<build> 
<pluginManagement> 
<plugins> 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>2.3</version> 
    <executions> 
     <execution> 
     <goals> 
      <goal>properties</goal> 
     </goals> 
     </execution> 
    </executions> 
</plugin> 

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.2</version> 

    <executions> 
     <execution> 
      <id>exec-one</id> 
      <phase>verify</phase> 
      <configuration> 
       <includeProjectDependencies>false</includeProjectDependencies> 
       <includePluginDependencies>true</includePluginDependencies> 
       <executableDependency> 
        <groupId>parent</groupId> 
        <artifactId>parent</artifactId> 
       </executableDependency> 

       <!-- Look up the main class from the manifest inside your dependency's JAR --> 
       <mainClass>mainclass</mainClass> 
       <arguments> 
       </arguments> 
      </configuration> 
      <goals> 
       <goal>java</goal> 
      </goals> 
     </execution> 
    </executions> 
     <dependencies> 
     <dependency> 
      <groupId>parent</groupId> 
      <artifactId>parent</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
      <scope>system</scope> 
      <systemPath>C:\....\parent.jar</systemPath> 
     </dependency> 
     </dependencies> 
</plugin>  
</plugins> 
</pluginManagement> 
</build> 
</project> 
+0

pom에 종속성으로 추가 했습니까? – pringi

+0

예, plz 내 아래 pom을 확인했습니다 – Jech

+0

당신이 뭘하고 싶은지 더 설명해 주시겠습니까? – pringi

답변

0

당신은 그것을 위해 받는다는 애그리 게이터 (aggregator) 프로젝트 치어를 사용할 수 있습니다.

예 :

<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 
         https://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>my-parent</artifactId> 
    <version>2.0</version> 
    <packaging>pom</packaging> 

    <modules> 
    <module>proj1</module> 
    <module>proj2</module> 
    </modules> 
</project> 

참고 Proj1 항상 proj2 전에 실행됩니다 이런 식으로.

나는 이것이 당신이 원하는 것이라고 생각합니다.

자세한 내용은 https://maven.apache.org/pom.html#Aggregation을 참조하십시오.

+0

'my-parent'유물이란 무엇입니까? 위의 예제는 내 proj2 pom의 내용입니까? – Jech

+0

시간이 없어서, 누군가 이걸 제안 해 주실 수 있습니다. – Jech

+0

당신이 원하는 것은 무엇이든간에. proj2 pom.xml은 proj2 (proj2는 proj2 pom이있는 디렉토리의 이름입니다)에 참조됩니다. 더 나은 개념을 이해하려면 maven 문서를 참조하십시오. – pringi