2011-09-06 4 views
1

구성 정보를 보유하고 zip 파일로 패키지 된 maven 프로젝트가 있습니다. maven 의존성 플러그인을 사용하여 내용을 $ {project.build.directory}/unpacked에 압축을 푼 다음 내용을 필터링하고 $ {project.build.directory}로 직접 덤프하는 리소스 플러그인을 실행합니다.maven exec 플러그인 - 로그백이 작동하지 않습니다.

maven exec를 실행하면 logback.xml이 선택되지 않습니다. 클래스 패스가 $ {basedir}로 설정되어 있지만 $ {project.build.directory}, 테스트 클래스, 클래스 및 클래스를 모두 갖고 싶습니다.

언제든지 classpath 요소를 추가하려고 할 때 구성 오류가 발생합니다.

이 문제를 해결하기 위해 pom.xml을 어떻게 구성해야합니까?

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

        <executions> 
         <execution> 
          <id>run</id> 
          <phase>package</phase> 
          <goals> 
           <goal>java</goal> 
          </goals> 
         </execution> 
        </executions> 

        <configuration> 
         <workingDirectory>${project.build.directory}</workingDirectory> 

         <mainClass>${jar.mainClass}</mainClass> 
        </configuration> 
       </plugin> 
+0

어떻게하면 maven exec를 호출하고 어떻게 구성합니까? – Cephalopod

+0

필자는 믿을 수있는 패키지 수명주기에 첨부하여이를 호출합니다. 필자는 특정 프로필, 실행 파일에 넣기 만하면 mvn clean package -Pexecutable이라고 말하면서 실행할 수 있습니다. – Walter

+0

기본적으로 빌드 디렉토리는 클래스 경로의 일부 여야합니다. 얼마나 정확하게 exec가 구성되고 logback.xml은 어디에 있습니까? – Cephalopod

답변

0

이렇게하면 문제가 해결됩니다.

 <plugin> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.3.1</version> 
      <configuration> 
       <archive> 
        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
        <manifest> 
         <addClasspath>true</addClasspath> 
         <!-- <classpathPrefix></classpathPrefix> --> 
         <mainClass>com.stackoverflow.test</mainClass> 
        </manifest> 

        <manifestEntries> 
         <Class-Path>${project.build.outputDirectory}/unpacked/logback.xml</Class-Path> 
        </manifestEntries> 
       </archive> 
      </configuration> 
     </plugin> 
관련 문제