Domanda

I have a project in which there are folder with different zip archives. I want to extract them and for each to make some checks. But want reports to be separated. For example pmd check. So to be separated files from each zip file has to be but in different sourseSets and when call

gradle check

For each of the dirs to generate reports with the checks.

Input files: sources1.zip,sources2.zip,sources3.zip,sources4.zip Each of the zip contains separate project. for example:

src/main/java/sources1/Example.java
src/main/java/sources2/App.java

.... When run checks to be generated

build/reports/pmd/sources1SourceSet.html
build/reports/pmd/sources2SourceSet.html
build/reports/pmd/sources3SourceSet.html
build/reports/pmd/sources4SourceSet.html

So I want to declare this different sourceSets according the name of the zips and not to do it manually, but don't know how.

sourceSets {
    sourcest1{
        java {
            srcDirs  file("...")
        }
    }
}

Is there are another easy way to separated checks without creating new sourceSets for each zip?

È stato utile?

Soluzione

one way to start you could create dedicated tasks for each zip. This can be done in a loop:

["source1", "source2", "source3"].each{ sourceName ->
    tasks.create("pmd${sourceName}", Pmd){
        reports.html.reportsDir = "$buildDir/reports/pmd${sourceName}"

        source = zipTree("file/to/$sourceName.zip")
        ...
    }
}

cheers

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top