2016-08-15 1 views
0

Android Studio에서 ar 패키지를 작성하려고합니다. 이 패키지는 Zendesk의 종속물을 포함합니다 :Gradle : 저장소에서 의존성을 포함하여 aar 파일을 출력하는 방법

allprojects { 
    repositories { 
     maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' } 
    } 
} 

compile (group: 'com.zendesk', name: 'sdk', version: '1.7.0.1') { 
    transitive = true 
} 

compile (group: 'com.zopim.android', name: 'sdk', version: '1.3.1.1') { 
    transitive = true 
} 

이 패키지를 Unity3d 프로젝트 용으로 빌드하려고합니다. 이 패키지는 Zendesk의 모든 의존성을 포함해야합니다 (transitive = true 속성). aar 파일을 열면 Zendesk에 대한 의존성이 없습니다. 뭐가 잘못 되었 니?

답변

3

기본적으로 AAR에는 종속성이 없습니다. 당신이 그 (것)들을 포함 할 경우, 수동으로 수행하여 패키지에 artifactory/캐시 폴더에서 이러한 libs와 복사하거나이 작업 당신을 도울 수 있습니다 https://stackoverflow.com/a/33539941/4310905

0

프로젝트를 컴파일 할 때,은이 컴파일 필요한 라이브러리와 비교하지만 라이브러리는 자동으로 패키지되지 않습니다.

"fatjar/uberjar"가 필요한 것은 Gradle shadow plugin입니다.

+0

하지만 해상도는 삭제됩니다. –

0

나는이 대답은 조금 늦게 온다 알고 있지만, 아직 ...

당신이 쓴 transitive PARAM은의 pom.xml 파일에 설정 될 필요가 이적 의존성 (당신의 의존성의 의존성)를 포함하는 것입니다 종속성을 compile으로 설정하십시오. 따라서 다른 용도로 사용하지 않는 한 aar 포장에 대해서는 실제로 그렇게 할 필요가 없습니다.

첫째, 당신은합니다 ( libs 폴더) 내부의 jar들과 aar 패키지 할 수 있습니다,하지만 당신은 aar 내부에 aar을 패키지 할 수 있다고 생각합니다. 문제를 해결하기

접근 방식은 다음과 같습니다.

  • 당신이에 관심이있는 종속성에서 해결 된 유물을 얻기 해결 유물의 사람이 jar 파일은
  • 확인합니다.
  • jar 인 경우 폴더에 복사하고 dependencies 폴더의 compile 폴더로 설정하십시오.

그래서 더 많거나 같은 덜 뭔가 :

configurations { 
    mypackage // create a new configuration, whose dependencies will be inspected 
} 

dependencies { 
    mypackage 'com.zendesk:sdk:1.7.0.1' // set your dependency referenced by the mypackage configuration 
    compile fileTree(dir: "${buildDir.path}/resolvedArtifacts", include: ['*.jar']) // this will compile the jar files within that folder, although the files are not there yet 
} 

task resolveArtifacts(type: Copy) { 
    // iterate over the resolved artifacts from your 'mypackage' configuration 
    configurations.mypackage.resolvedConfiguration.resolvedArtifacts.each { ResolvedArtifact resolvedArtifact -> 

     // check if the resolved artifact is a jar file 
     if ((resolvedArtifact.file.name.drop(resolvedArtifact.file.name.lastIndexOf('.') + 1) == 'jar')) { 
      // in case it is, copy it to the folder that is set to 'compile' in your 'dependencies' closure 
      from resolvedArtifact.file 
      into "${buildDir.path}/resolvedArtifacts" 
     } 
    } 
} 

이제 ./gradlew clean resolveArtifacts build을 실행할 수 있으며, aar 패키지 안에 해결 jar들 것이다.

이 정보가 도움이되기를 바랍니다.