2014-11-04 3 views
0

아이비 기능에 의존적 인 의존성을 해결하는 사용자 정의 빌드 도구가 있습니다. 종속성의 구성은 ivy.xml 파일이 아니라 사용자 정의 구성을 허용합니다. 핵심은 프로그램 방식으로 아이비를 사용한다는 것입니다. 종속성 (그룹 ID, 이슈 ID, 버전)을 감안할 때 프로그래밍 방식으로 아이비 가져 오기 소스가 있음

, 우리는 ModuleRevisionId을 만듭니다
ModuleRevisionId id = ModuleRevisionId.newInstance(orgName, moduleName, revisionName); 

는 ModuleDescriptor 하였다. 이것은 아이비에게 내가 소스가 될뿐만 아니라 타겟 라이브러리 jar 파일을 원한다는 것을 알리기에 충분하지 않다는 것을 짐작하고있다. ModuleDescriptor를 만들 때 DependencyConfiguration이 대 무엇 '구성'인지 대개 확실하지 않습니다.

DefaultModuleDescriptor md 
    = new DefaultModuleDescriptor(
     ModuleRevisionId.parse("org#standalone;working"), 
     "integration", 
     new java.util.Date()); 
DefaultDependencyDescriptor mainDep 
    = new DefaultDependencyDescriptor(id, /* force = */ true); 
mainDep.addDependencyConfiguration("compile", "compile"); 
mainDep.addDependencyConfiguration("compile", "sources"); 
md.addDependency(mainDep); 
md.addConfiguration(new Configuration("compile")); 
md.addConfiguration(new Configuration("sources")); 

위의 내용과 RetrieveOptions 대 ResolveOptions은 실제로 이해할 수 없습니다.

술이 필요합니다.

답변

0

자, 시간이 좀 걸렸지 만 마침내이 중 일부를 머리에 감았습니다.

// define 'our' module 
DefaultModuleDescriptor md 
    = new DefaultModuleDescriptor(ModuleRevisionId.parse("org#standalone;working"), 
           /* status = */ "integration", 
           new java.util.Date()); 
// add a configuration to our module definition 
md.addConfiguration(new Configuration("compile")); 

// define a dependency our module has on the (third party, typically) dependee module 
DefaultDependencyDescriptor mainDep = new DefaultDependencyDescriptor(md, dependeeModuleId, /* force = */ true, false, true); 
mainDep.addDependencyConfiguration("compile", "default"); 
mainDep.addDependencyConfiguration("compile", "sources"); 

// define which configurations we want to resolve (only have 1 in this case anyway) 
ResolveOptions resolveOptions = new ResolveOptions(); 

String[] confs = new String[] {"compile"}; 
resolveOptions.setConfs(confs); 

resolveOptions.setTransitive(true); // default anyway 
resolveOptions.setDownload(true); // default anyway 

ResolveReport report = ivy.resolve(md, resolveOptions); 

이렇게하면 기본 jar와 소스 대상이 모두 풀다운됩니다. 담쟁이에는 일시적으로 소스를 가져 오지 않는 문제가 있지만 '메인'항아리를 일시적으로 가져옵니다. 따라서 하위 종속성이 아니라 여기에 정의 된 즉각적인 종속성에 대한 소스 만 얻을 수 있습니다.

필자가 알아 내려고하는 또 다른 단점은 대상 종속성에 '원본'구성이 있다고 가정한다는 것입니다. 차라리 형식 소스/소스/src의 유물을 얻으려고 말할 것입니다. 아직 그걸 알아 내지 못 했어.