maven插件测试与maven 3.0.4不兼容

发布于 2025-01-05 03:47:58 字数 2609 浏览 2 评论 0原文

我对maven插件有一个简单的测试:

public class SimpleMavenTest extends AbstractMojoTestCase {

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        // code
    }

    public void testCase() throws Exception {
        // test case
    }

    @Override
    protected void tearDown() throws Exception {
        // code
        super.tearDown();
    }
}

使用这样的 maven-surefire-plugin配置:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <forkMode>never</forkMode>
      </configuration>
    </plugin>
  </plugins>
</build>

直到maven 3.0.4发布后,我的SimpleMavenTest运行成功。但是当我使用maven 3.0.4运行测试时,发生了下一个错误:

java.lang.IllegalStateException: The internal default plexus-bootstrap.xml is missing. This is highly irregular, your plexus JAR is most likely corrupt.
    at org.codehaus.plexus.DefaultPlexusContainer.initializeConfiguration(DefaultPlexusContainer.java:1052)
    at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:627)
    at org.codehaus.plexus.PlexusTestCase.setUp(PlexusTestCase.java:119)
    at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:69)
    at org.maven.test.MyMojoTest.setUp(MyMojoTest.java:12)
    at junit.framework.TestCase.runBare(TestCase.java:128)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

我在这里查看: http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html 并尝试更改maven-surefire-plugin 以这样的方式配置:

<configuration>
        <forkMode>once</forkMode>
</configuration>

一切正常。但是如果我make:

<forkMode>never</forkMode>

就会出现上面的错误。这很奇怪,因为在 maven 3.0.3 和以前的 maven 版本上,测试运行没有任何错误。有什么想法吗?

I have a simple test for maven plugin:

public class SimpleMavenTest extends AbstractMojoTestCase {

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        // code
    }

    public void testCase() throws Exception {
        // test case
    }

    @Override
    protected void tearDown() throws Exception {
        // code
        super.tearDown();
    }
}

with such maven-surefire-plugin configuration:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <forkMode>never</forkMode>
      </configuration>
    </plugin>
  </plugins>
</build>

Until maven 3.0.4 has been released, my SimpleMavenTest run succesfully. But when I run the test using maven 3.0.4, the next error was occurred:

java.lang.IllegalStateException: The internal default plexus-bootstrap.xml is missing. This is highly irregular, your plexus JAR is most likely corrupt.
    at org.codehaus.plexus.DefaultPlexusContainer.initializeConfiguration(DefaultPlexusContainer.java:1052)
    at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:627)
    at org.codehaus.plexus.PlexusTestCase.setUp(PlexusTestCase.java:119)
    at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:69)
    at org.maven.test.MyMojoTest.setUp(MyMojoTest.java:12)
    at junit.framework.TestCase.runBare(TestCase.java:128)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I looked here: http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html and tried to change maven-surefire-plugin configuration in a such way:

<configuration>
        <forkMode>once</forkMode>
</configuration>

Everything works fine. But if I make:

<forkMode>never</forkMode>

the above error is occured. It's strange, because on maven 3.0.3 and previous maven versions the test was run without any errors. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

千寻… 2025-01-12 03:47:58

我在 jira.codehaus.org 上打开了 a bug 并得到了此问题已解决的答案在 maven-surefire-plugin v.2.11 中。由于我使用的是2.10版本,所以出现了错误。最新的surefire插件版本是2.12,因此更改surefire配置如下:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
    <configuration>
        <forkMode>never</forkMode>
    </configuration>
</plugin>

测试将成功运行。

I opened a bug on jira.codehaus.org and got the answer that this trouble was resolved in maven-surefire-plugin v.2.11. As I used 2.10 version, the error was occurred. The latest surefire plugin version is 2.12, so change surefire configuration as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
    <configuration>
        <forkMode>never</forkMode>
    </configuration>
</plugin>

and tests will run successfully.

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