How to configure JaCoCo maven plugin from command line

前端 未结 3 447
执笔经年
执笔经年 2021-01-12 04:58

I\'m trying to configure JaCoCo maven plugin from command line insted of using pom.xml. I have managed to execute prepare-agent so far with command

3条回答
  •  迷失自我
    2021-01-12 05:22

    When You can not use property, you can use environment variable.

    When I get Jacoco Diff Coverage jacoco:report includes cannot use property.

    So I use ${inc_files}

    Shell:

    echo "+++git diff+++"
    inc_files=`git diff --name-only master | grep -oP 'com/languoguang/xxclouds/quark.*.java' | xargs | sed 's/.java/.class/g' | xargs | sed -e 's/ /,/g'`;
    echo ${inc_files};
    echo "---git diff---";
    
    echo "+++maven test jacoco+++";
    mvn -B -f pom.xml -Dinc_files=${inc_files} clean test -Dmaven.test.failure.ignore=true;
    echo "---maven test jacoco---";
    

    pom.xml:

    
        
            quark-frameworks-coverage-inc
            ${project.reporting.outputDirectory}/jacoco-aggregate/jacoco-aggregate-inc/
            ${inc_files}
        
        report-aggregate-inc
        test
        
            report-aggregate
        
    
    

    I hope this will be useful.

提交回复
热议问题