Maven:如何为插件执行添加自定义类路径条目?
更新:一开始似乎是 SoapUI maven 插件特定的问题,但实际上并非如此,所以请仔细阅读。
我正在使用 Maven2 运行 SoapUI 插件,如下所示:
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<settingsFile>${basedir}/src/test/resources/soapui-settings.xml</settingsFile>
<projectFile>${basedir}/src/test/resources/my-soapui-project.xml</projectFile>
<outputFolder>${project.build.directory}/soapui-output</outputFolder>
<printReport>true</printReport>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>${project.build.directory}/soapui-logs/</value>
</property>
</soapuiProperties>
</configuration>
</plugin>
它工作完美,并将所有soapui日志文件放入 ${project.build.directory}/soapui-logs/
中,但有一个例外:global- groovy.log
进入 basedir (似乎是 SoapUI log4j 配置中的错误)。
我需要一个选项来覆盖 SoapUi maven 插件附带的 soapui-log4j.xml
文件,并修复 GLOBAL_GROOVY_LOG
附加程序:
<param name="File" value="global-groovy.log"/>
到此:
<param name="File" value="${soapui.logroot}global-groovy.log"/>
在过去,我以编程方式运行 SoapUI 测试JUnit 测试并将更新的 soapui-log4j.xml
文件放入 src/test/resources/com/eviware/soapui/resources/conf/soapui-log4j.xml
中工作了。 Maven 将其复制到 target/test-classes
中,并将该路径添加到 classpath
中以运行单元测试。
现在 SoapUI maven 插件的问题是我不知道如何将 src/test/resources/com/eviware/soapui/resources/conf/soapui-log4j.xml 添加到插件的 类路径。有没有类似Surefire的
additionalClasspathElements
配置选项?
换句话说,我想知道如何向任何通用 Maven 插件执行环境添加额外的类路径条目,而不仅仅是 SoapUI 插件。
UPDATE: It seems to be SoapUI maven plugin specific issue at first, but it's not, really, so please read through.
I'm running SoapUI plugin with Maven2 like this:
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<settingsFile>${basedir}/src/test/resources/soapui-settings.xml</settingsFile>
<projectFile>${basedir}/src/test/resources/my-soapui-project.xml</projectFile>
<outputFolder>${project.build.directory}/soapui-output</outputFolder>
<printReport>true</printReport>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>${project.build.directory}/soapui-logs/</value>
</property>
</soapuiProperties>
</configuration>
</plugin>
It works perfectly and puts all soapui log files into ${project.build.directory}/soapui-logs/
with one exception: global-groovy.log
which goes into basedir (seems to be bug in SoapUI log4j configuration).
I need an option to override soapui-log4j.xml
file that comes with SoapUi maven plugin and fix GLOBAL_GROOVY_LOG
appender from:
<param name="File" value="global-groovy.log"/>
to this:
<param name="File" value="${soapui.logroot}global-groovy.log"/>
In the past I ran SoapUI test programmatically from JUnit test and just placed updated soapui-log4j.xml
file into src/test/resources/com/eviware/soapui/resources/conf/soapui-log4j.xml
and it worked. Maven copies it into target/test-classes
and adds that path to classpath
to run unit tests.
Now the problem with SoapUI maven plugin is that I don't know how to add src/test/resources/com/eviware/soapui/resources/conf/soapui-log4j.xml
to plugin's classpath
. Is there anything similar to Surefire's additionalClasspathElements
configuration option?
So in other words I want to know how to add additional class path entries to any generic maven plugin execution environment, not only SoapUI plugin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用 添加插件依赖项依赖项 元素。来自 POM 参考:
我不知道maven如何处理这些依赖项,因此它可能会将它们放在插件自己的类之后,这有效地防止覆盖log4j配置,但尝试一下;将 log4j 配置文件打包到 jar 中,并将其作为依赖项添加到插件中。
It's possible to add to a plugins dependencies using the dependencies element. From the POM reference:
I don't know how maven treats these dependencies, so it might place them after the plugin's own classes which effectively prevents overriding the log4j configuration, but give it a try; package the log4j configuration file in a jar and add it as a dependency to the plugin.