1
我跟着這個例子中,以獲得所需的依賴注入我的AbtractMavenLifecyleParticipant:如何使用奧德在org.apache.maven.AbstractMavenLifecycleParticipant
http://www.sonatype.com/people/2011/01/how-to-use-aether-in-maven-plugins/
http://maven.apache.org/examples/maven-3-lifecycle-extensions.html
'afterProjectsRead'被完美調用,但是repoSystem,repoSession和remoteRepos總是'null 」。
如何從AbstractMavenLifecyleParticipant中獲取這些對象?
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.MavenExecutionException;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.annotations.Component;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.repository.RemoteRepository;
@Component(role = AbstractMavenLifecycleParticipant.class, hint = "skipper")
public class ModuleSkipperLifecycleParticipant extends AbstractMavenLifecycleParticipant {
/**
* @component
*/
private RepositorySystem repoSystem;
/**
* @parameter default-value="${repositorySystemSession}"
* @readonly
*/
private RepositorySystemSession repoSession;
/**
* @parameter default-value="${project.remotePluginRepositories}"
* @readonly
*/
private List<RemoteRepository> remoteRepos;
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
super.afterProjectsRead(session);
System.out.println("repoSession: " + repoSession);
System.out.println("repoSystem: " + repoSystem);
System.out.println("remoteRepos: " + remoteRepos);
}
}
看起來很棒,第一次測試,似乎工作 - 我會給它更詳細的測試。非常感謝現在!!!!! – domi
雖然我不是使用這個圖書館,它給了我正確的提示 - 謝謝! – domi
不客氣:) – yegor256