Maven:如何为插件执行添加自定义类路径条目?

发布于 2024-10-18 16:35:33 字数 2147 浏览 7 评论 0原文

更新:一开始似乎是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事还在继续 2024-10-25 16:35:33

可以使用 添加插件依赖项依赖项 元素。来自 POM 参考:

该项目需要引入插件的类加载器的其他依赖项。

我不知道maven如何处理这些依赖项,因此它可能会将它们放在插件自己的类之后,这有效地防止覆盖log4j配置,但尝试一下;将 log4j 配置文件打包到 jar 中,并将其作为依赖项添加到插件中。

It's possible to add to a plugins dependencies using the dependencies element. From the POM reference:

Additional dependencies that this project needs to introduce to the plugin's classloader.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文