有人知道如何改变吗?
我的意思是
target/test-classes ... target/classes .... maven dependencies
到
target/test-classes ... maven dependencies .... target/classes
它涉及此surefire-plugin feature request
这是因为surefire-plugin不能包含/排除/ target / classes中的资源...它只能通过<testResources>
元素包含/排除资源,这只会影响/ target / test-classes,而不是/ target /类
这一切都发生在Surefire-plugin:
File projectClassesDirectory = new File( project.getBuild().getOutputDirectory() );
if ( !projectClassesDirectory.equals( classesDirectory ) )
{
int indexToReplace = classpathElements.indexOf( project.getBuild().getOutputDirectory() );
if ( indexToReplace != -1 )
{
classpathElements.remove( indexToReplace );
classpathElements.add( indexToReplace, classesDirectory.getAbsolutePath() );
}
else
{
classpathElements.add( 1, classesDirectory.getAbsolutePath() );
}
}
File projectTestClassesDirectory = new File( project.getBuild().getTestOutputDirectory() );
if ( !projectTestClassesDirectory.equals( testClassesDirectory ) )
{
int indexToReplace = classpathElements.indexOf( project.getBuild().getTestOutputDirectory() );
if ( indexToReplace != -1 )
{
classpathElements.remove( indexToReplace );
classpathElements.add( indexToReplace, testClassesDirectory.getAbsolutePath() );
}
else
{
classpathElements.add( 0, testClassesDirectory.getAbsolutePath() );
}
}
getLog().debug( "Test Classpath :" );
for ( Iterator i = classpathElements.iterator(); i.hasNext(); )
{
String classpathElement = (String) i.next();
getLog().debug( " " + classpathElement );
surefireBooter.addClassPathUrl( classpathElement );
}
答案 0 :(得分:1)
考虑在单独的项目中进行测试。一般来说,当你有一个与The Maven Way冲突的项目时,这就是解决方案 - 将其拆分。
答案 1 :(得分:0)