我正在尝试为我的代码设置我的第一个maven项目,可在此处找到: https://github.com/jkinable/jorlib
我有3个pom文件:
我想从编译和测试中排除以下目录中的所有文件:
jorlib-core/src/test/java/org/jorlib/frameworks/columnGeneration/tsp
请注意“测试”部分。根据这个website,我可以将maven-compiler-plugin与excludes和testExcludes一起使用。所以我添加了插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<excludes>
<exclude>**/org/jorlib/frameworks/columnGeneration/tsp/**</exclude>
<exclude>**/org/jorlib/frameworks/columnGeneration/tsp/**/*</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/**/*</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/Master.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/TSPMasterData.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/ExactPricingProblemSolver.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/cuts/SubtourInequalityGenerator.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/cuts/SubtourInequalityGenerator.java</exclude>
<exclude>**/src/**test**/java/org/jorlib/frameworks/columnGeneration/tsp/**/*</exclude>
<exclude>**/src/**test**/java/org/jorlib/frameworks/columnGeneration/tsp/**</exclude>
<exclude>**/src/**test**/java/org/jorlib/frameworks/columnGeneration/tsp/*</exclude>
</excludes>
<testExcludes>
<exclude>**/frameworks/**</exclude>
<exclude>**/org/jorlib/frameworks/columnGeneration/tsp/**</exclude>
<exclude>**/org/jorlib/frameworks/columnGeneration/tsp/**/*</exclude>
<exclude>/org/jorlib/frameworks/**</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/*</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/**/*</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/Master.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/TSPMasterData.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/ExactPricingProblemSolver.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/cuts/SubtourInequalityGenerator.java</exclude>
<exclude>**/src/test/java/org/jorlib/frameworks/columnGeneration/tsp/cg/master/cuts/SubtourInequalityGenerator.java</exclude>
<exclude>**/src/**test**/java/org/jorlib/frameworks/columnGeneration/tsp/**/*</exclude>
<exclude>**/src/**test**/java/org/jorlib/frameworks/columnGeneration/tsp/**</exclude>
<exclude>**/src/**test**/java/org/jorlib/frameworks/columnGeneration/tsp/*</exclude>
</testExcludes>
</configuration>
我尝试了大量的排除规则(以上只是一小部分)。我运行“mvn clean; mvn test”但仍然在
中的类上继续编译错误jorlib-core/src/test/java/org/jorlib/frameworks/columnGeneration/tsp
有关如何处理此事的任何建议?
答案 0 :(得分:0)
解决方案似乎很简单。以下代码就足够了(请注意testExcludes的命令):
// get current client timezone with jstimezonedetect
var currentTz = jstz.determine().name(); // e.g "Europe/London"
// parse last update time to moment object and change its timezone
var lastUpdateTime = moment(lastUpdatedTime, "M/DD/YYYY hh:mm a").tz(currentTz);
// create date using moment and deduct 20 mins from it
var deductTwenty = moment().subtract(20, 'minutes');
// now compare
if (lastUpdateTime > deductTwenty) {
newrestartButton.hide();
}
这对我没有用,因为我的代码中的其他地方我有一个孤独的import语句,它从我想要排除的目录中导入了一个文件。虽然这个特殊的文件根本没用过(我只是忘了删除import语句),但是单独的import语句导致maven无论如何都要编译被排除的目录。让我想知道为什么maven没有发现这个&#39;冲突&#39;?尽管如此,我很高兴地报告我的问题已经解决了。