2012-05-18 4 views
1

일부 플러그인을 만들려고합니다. 설치 단계 직후 artifact 및 pom.xml에 대한 경로를 가져와야합니다.플러그인의 로컬 .m2 repo 경로 pom.xml

D :

D :이 같은 첫-1.0-SNAPSHOT.jar

그리고 pom.xml 파일 경로 \ \ 작업 \ 테스트 \ MVN \ moduleFirst \ 대상이 같은 유물 경로를 가지고 \ 작업 \ 테스트 \ MVN \ moduleFirst \의 pom.xml

그러나 pom.xml 파일 패키지에 "치어"로 설정하는 경우, 나는이 같은 유물 경로 가지고

:

C : \ 사용자 \ user.m2 저장소 \ \ com \ test \ mvn \ 1.0-SNAPSHOT \ mvn-1.0-SNAPSHOT.pom

과의 pom.xml :

D : \ 작업 \ 테스트 \ MVN \의 pom.xml

내가 .m2 지역의 repo에서 모든 경로를 얻을 싶습니다. 어떻게 가능할까요?

... 
    /** 
    * @parameter default-value="${project.file}" 
    */ 
    private File pomFile; 
... 
    /** 
    * @parameter default-value="${project.artifact}" 
    */ 
    private Artifact artifact; 
... 
    public void execute() throws MojoExecutionException { 
... 
     getLog().info("POM file " + pomFile.getAbsolutePath()); 
     getLog().info("Artifact " + artifact.getFile().getAbsolutePath()); 
... 
    } 

답변

0

내가 해결책을 발견 :

나는 다음과 코드를 확인하십시오.

... 
    /** 
    * @parameter expression="${localRepository}" 
    * @required 
    * @readonly 
    */ 
    protected ArtifactRepository localRepository; 
... 
    protected String getLocalRepoFile(Artifact artifact) { 
     File file = new File(localRepository.getBasedir(), localRepository.pathOf(artifact)); 
     return file.getAbsolutePath(); 
    } 
... 
    public void execute() throws MojoExecutionException { 
... 
getLog().info("Artifact " + getLocalRepoFile(artifact)); 
... 
    } 

감사하는 받는다는 설치 - 플러그인 :