场景描述
因实验需要,收集了一些Maven project在Ubuntu 16.04 LTS上进行mvn test/mvn compile等操作。有时会发生BUILD FAILURES。本文描述几个详细的案例及解决方案,供以后遇到类似情况参考。
HikariCP
project地址:https://github.com/brettwooldridge/HikariCP.git
表现:某个test异常卡顿(OSGI这个test),出现HTTPS 501问题,然后该test fail导致BUILD FAILURES。
分析:查找发现HTTPS 501的原因是默认没有使用https的central源,在2020年1月后强制使用https,否则就会报501错误。在更换maven源之后仍然没有解决这个问题。
解决方案:在pom.xml的surefire configuration里配置exclude该test,问题解决(基本不影响执行时间)。
log4j
project地址:https://github.com/apache/log4j.git
表现:使用python脚本os.system(“mvn test >> output.txt”)
分析:log4j可能在测试中使用了某些输入输出流,与脚本中的流冲突导致fail。
解决方案:尝试手动mvn test,问题解决。
java-apns
project地址:https://github.com/notnoop/java-apns.git
表现:integration test中的FeedbackTest出现大量Exception,然后build流程卡顿不动。具体见https://github.com/notnoop/java-apns/issues/370。
分析:尝试用类似于HikariCP的解决方案exclude FeedbackTest,然而其它integration test也出现error。把整个integration test都exclude后,剩余BUILD时间只有15秒左右,执行时间变化很大。
解决方案:目前未解决。TODO
OpenTripPlanner
project地址:https://github.com/opentripplanner/OpenTripPlanner.git
表现:使用alimaven源出现大量Could not resolve artifact,在compile阶段开始前即BUILD FAILURES。
分析:查找发现此类问题大概率是由网络问题导致。在把alimaven源还原成central源后,download速率变慢很多,但仍未解决could not resolve artifact。
解决方案:更改pom.xml的配置,原有pom中配置的源是硬编码的已经失效。更改一些依赖的版本号。