使用maven-compiler和jdk9-ea + 148编译测试 [英] compile tests using maven-compiler and jdk9-ea+148

查看:192
本文介绍了使用maven-compiler和jdk9-ea + 148编译测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用maven-compile-plugin构建我的应用程序时遇到问题:3.6.0 at jdk9-ea + 148。

I have problem with building my application using maven-compile-plugin:3.6.0 at jdk9-ea+148.

我正在尝试制作jdk9模块。模块信息和其他类正在编译而没有问题,但是当涉及到default-testCompile时它就崩溃了。当我的module-info.java被删除时,它被编译没有问题。

I am trying to make jdk9 module. Module-info and other classes are getting compiled without problem, but when it comes to default-testCompile it just crashes. When my module-info.java is removed, the it is compiled without problems.

基本上这是我得到的例外:

Basically this is the exception I am getting:


Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile (default-testCompile) on project bar: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile (default-testCompile) on project bar: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile failed.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:538)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile failed.
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        ... 20 more
Caused by: java.lang.NullPointerException
        at org.apache.maven.plugin.compiler.AsmModuleInfoParser.getModuleName(AsmModuleInfoParser.java:48)
        at org.apache.maven.plugin.compiler.TestCompilerMojo.preparePaths(TestCompilerMojo.java:259)
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:742)
        at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:164)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 21 more

这是我在那里的maven-compiler-plugin的设置

This is the settings of maven-compiler-plugin I have there

<plugins>
 <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.6.0</version>
  <configuration>
   <source>1.9</source>
   <target>1.9</target>
   <compilerArgument>-Xlint:all</compilerArgument>
  </configuration>
 </plugin>
</plugins>

有谁知道如何处理这个问题才能使它有效?

Does anyone know what to do with this problem to make it work?

推荐答案

当Maven尝试读取 module-info.class 的类名时发生异常因为指定了最近的更改为空。看起来Maven使用ASM并根据Remi Forax ASM6应该已经处理过这种情况

The exception occurs when Maven tries to read the module-info.classs class name, which since a recent change was specified to be null. It looks like Maven uses ASM and according to Remi Forax ASM6 should already handle that case.

我建议在Maven问题跟踪器中查找问题,如果无法找到则打开一个。

I suggest looking for an issue in the Maven issue tracker and open one if it can't be found.

这篇关于使用maven-compiler和jdk9-ea + 148编译测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆