我最终使用GMaven:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
def all = project.runtimeArtifacts.collect{
def aid = "${it.groupId}:${it.artifactId}:${it.version}"
def p = project.projectReferences[aid]
p?.build?.outputDirectory ?: it.file.path
} + project.build.outputDirectory
def file = new File(project.build.directory, ".classpath")
file.write(all.join(File.pathSeparator))
</source>
</configuration>
</execution>
</executions>
</plugin>
的代码,因为我想的路径来定位有点复杂/班如果可能。如果不需要,可以这样做:
file.write(project.runtimeClasspathElements.join(File.pathSeparator))
测试的类路径是自动生成的。那么特定问题在哪里?或者你是在谈论一种集成测试而不是单元测试? (Multimodule build?) – khmarbaise 2010-10-17 12:37:06
在一个组件中,我为另一个组件创建一个ClassLoader。在生产中,classpath是lib/*,但在测试中我不想通过打包 – IttayD 2010-10-17 13:19:58