【问题标题】:gwt-maven-plugin does load the "main" log4j configuration instead of the "test" onegwt-maven-plugin 确实加载“主”log4j 配置而不是“测试”配置
【发布时间】:2016-10-26 16:11:28
【问题描述】:

在我的 maven 项目中,我有不同的 log4j 配置用于开发和集成环境,也有不同的用于测试目的的配置,而不是我的 webapp 的主要用途。位于:

  • src/main/resources/dev/log4j.properties
  • src/main/resources/int/log4j.properties
  • src/test/resources/dev/log4j_test.properties
  • src/test/resources/int/log4j_test.properties

所以我有不同的配置文件(DEV / INT)来管理这些差异......

为了确保安全(用于单元测试)和故障安全(用于集成测试)插件,我添加了一些配置:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.19.1</version>
  <executions>
    <execution>
    <goals>
      <goal>integration-test</goal>
      <goal>verify</goal>
    </goals>
    </execution>
  </executions>
  <configuration>
    <systemPropertyVariables>
    <log4j.configuration>file:${basedir}/${profile.test.resource}/log4j_test.properties</log4j.configuration>
    </systemPropertyVariables>
    <!-- Stop the integration tests after the first failure to keep in database
    the content of the failed test. -->
    <skipAfterFailureCount>1</skipAfterFailureCount>
    <includes>
    <!-- Include only integration tests -->
    <include>**/*IntegrationTest.java</include>
    </includes>
    <skip>${skip.integration.tests}</skip>
  </configuration>
</plugin>

但现在我正在为 DEV 模式下的 GWT 特定单元测试添加 gwt-maven-plugin。

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>gwt-maven-plugin</artifactId>
  <version>2.7.0</version>
  <executions>
    <execution>
      <goals>
        <goal>compile</goal>
        <goal>i18n</goal>
        <goal>generateAsync</goal>
        <goal>test</goal>
      </goals>
    </execution>
  </executions>

  <configuration>
    <runTarget>Appication.html</runTarget>
    <webappDirectory>${webappDirectory}</webappDirectory>
    <hostedWebapp>${webappDirectory}</hostedWebapp>
    <i18nMessagesBundles>
      ...               
    </i18nMessagesBundles>

    <extraJvmArgs>${gwt.extra.args}</extraJvmArgs>
    <style>${compile.style}</style>
    <module>${module.name}</module>
  </configuration>
</plugin>

是否可以将其配置为指向特定/过滤的 lop4j,就像我为确保万无一失和故障安全所做的那样?*

谢谢,

【问题讨论】:

    标签: unit-testing logging gwt jenkins gwt-maven-plugin


    【解决方案1】:

    您可以在extraJvmArgs中传递系统属性

    【讨论】:

    • 谢谢。毕竟相当明显和简单...... :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多