2013-07-19 2 views
0

다중 프로젝트 빌드가 있습니다. 빌드의 일부 프로젝트는 테스트 결과를 생성합니다. 하나의 프로젝트가 설치 프로그램을 생성하고,이 프로젝트의 아티팩트에 다른 모든 프로젝트의 테스트 결과를 포함시키고 싶습니다. 그래서,Gradle 빌드 수명주기 후반 작업 설정

// Empty test task, so that we can make the gathering of test results here depend on the tests' having 
// been run in other projects in the build 
task test << { 
} 

def dependentTestResultsDir = new File(buildDir, 'dependentTestResults') 

task gatherDependentTestResults(type: Zip, dependsOn: test) { 

    project.parent.subprojects.each { subproject -> 

     // Find projects in this build which have a testResults configuration 
     if(subproject.configurations.find { it.name == 'testResults' }) { 

      // Extract the test results (which are in a zip file) into a directory 
      def tmpDir = new File(dependentTestResultsDir, subproject.name) 
      subproject.copy { 
       from zipTree(subproject.configurations['testResults'].artifacts.files.singleFile) 
       into tmpDir 
      } 
     } 
    } 

    // Define the output of this task as the contents of that tree 
    from dependentTestResultsDir 
} 

문제는이 작업이 구성되어있는 점에서, 다른 프로젝트에서 테스트 작업을 실행하지 않은 것을 : 나는 (설치 프로그램을 생산하는 프로젝트에서) 이런 그렇게 시도 이들 유물은 존재하지 않으며, 나는이처럼 내 빌드하는 동안 메시지를 얻을 :

The specified zip file ZIP 'C:\[path to project]\build\distributions\[artifact].zip' does not exist and will be silently ignored. This behaviour has been deprecated and is scheduled to be removed in Gradle 2.0 

그래서 나는 테스트 아티팩트가 실제로 제작 될 때까지 지연되고 내 작업의 구성을 포함 할 것이다 뭔가를 할 필요가있다. 이것을 달성하는 관용적 인 방법은 무엇입니까?

저는 Gradle에 관해서 자주 이런 질문에 답할 필요가있는 것처럼 보입니다. 나는 개념적으로 뭔가를 놓치고 있다고 생각한다. 작업이 항상 대로 간주됩니다 -

해당 인스턴스에서

답변

1

, 당신은 나를 위해 작동하지 않는 것

task gatherDependentTestResults(type: Zip, dependsOn: test) << { 
    // your task code here 
} 
+0

이 같이 <<을 추가해 작업을 할 수 있어야한다 날짜. 이 작업은 Zip 또는 유사해야합니다. 아티팩트 스크립트 블록에서이 작업을 사용할 것이기 때문에 Zip 작업이 구성되지 않도록 코드에 넣으면됩니다. 그게 무슨 일이야). –

+1

zip 작업이 의존하는 다른 작업을 추가하고 해당 작업을 사용하여 (zip 작업의) 구성을 수행하십시오. – Matt