Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public class CoverBaseRequest {
*/
private String subModule;

/**
* 同一个git仓库可能存在多个模块,excludeModule为相对路径,当工程模块中不需要统计此模块时进行配置
* 例如: assembly
*/
private String excludeModule;

/**
* 1、全量;2、增量
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.xiaoju.basetech.entity.*;
import com.xiaoju.basetech.service.CodeCovService;
import com.xiaoju.basetech.util.*;
import java.util.Arrays;
import jodd.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
Expand Down Expand Up @@ -305,6 +306,30 @@ public void triggerEnvCov(EnvCoverRequest envCoverRequest) {
log.info("{}计算覆盖率具体步骤...计算增量代码失败,uuid={}", Thread.currentThread().getName(), coverageReport.getUuid());
return;
}
}else {
// 将配置的 subModule 和 excludeModule进行处理
DeployInfoEntity deployInfo = new DeployInfoEntity();
deployInfo.setUuid(coverageReport.getUuid());
deployInfo.setCodePath(coverageReport.getNowLocalPath());
if (StringUtils.isEmpty(envCoverRequest.getSubModule())){
String pomPath = deployInfo.getCodePath() + "/pom.xml";
ArrayList<String> moduleList = MavenModuleUtil.getValidModules(pomPath);
// 将需要排除的模块进行处理
if (!StringUtils.isEmpty(envCoverRequest.getExcludeModule())){
String[] excludeModules = envCoverRequest.getExcludeModule().split(",");
// 删除掉需要排除的模块
moduleList.removeAll(Arrays.asList(excludeModules));
}
StringBuilder moduleNames = new StringBuilder("");
for (String module : moduleList) {
moduleNames.append(module + ",");
}
deployInfo.setChildModules(moduleNames.toString());
}else {
// 只处理指定的模块
deployInfo.setChildModules(envCoverRequest.getSubModule());
}
deployInfoDao.updateDeployInfo(deployInfo);
}
calculateEnvCov(coverageReport);
}).start();
Expand Down Expand Up @@ -337,10 +362,13 @@ public void calculateEnvCov(CoverageReportEntity coverageReport) {

if (exitCode == 0) {
CmdExecutor.executeCmd(new String[]{"rm -rf " + REPORT_PATH + coverageReport.getUuid()}, CMD_TIMEOUT);
String[] moduleList = deployInfoEntity.getChildModules().split(",");
String[] moduleList = {};
if (!StringUtils.isEmpty(deployInfoEntity.getChildModules())){
moduleList = deployInfoEntity.getChildModules().split(",");
}
StringBuilder builder = new StringBuilder("java -jar " + JACOCO_PATH + " report " + deployInfoEntity.getCodePath() + "/jacoco.exec ");
// 单模块的时候没有moduleList
if (moduleList.length == 0) {
if (moduleList == null || moduleList.length == 0) {
builder.append("--sourcefiles ./src/main/java/ ");
builder.append("--classfiles ./target/classes/com/ ");
} else {
Expand Down