我正在使用Maven插件为一种新语言构建一个NetBeans插件。我大致遵循了本教程,但最终无法编译(下面是堆栈跟踪)。
使用与标准(基于Ant的)NetBeans模块项目相同的代码和模块依赖关系,它可以正确编译。它找不到的类似乎在另一个模块(org.netbeans模块编辑器代码模板)中可用,但当我使用基于Ant的项目时,我不需要那个模块。此外,如果我添加了那个模块,我会在另一个模块中找不到的另一个类中出现类似的错误,这让我觉得我做错了什么。我是不是错过了什么?
堆栈跟踪:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NoClassDefFoundError: org/netbeans/lib/editor/codetemplates/CodeTemplateCompletionProvider
at org.netbeans.modules.csl.core.LanguageRegistrationProcessor.registerCodeCompletion(LanguageRegistrationProcessor.java:270)
at org.netbeans.modules.csl.core.LanguageRegistrationProcessor.handleProcess(LanguageRegistrationProcessor.java:160)
at org.openide.filesystems.annotations.LayerGeneratingProcessor.process(LayerGeneratingProcessor.java:121)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:342)
at com.sun.tools.javac.main.Main.compile(Main.java:333)
at com.sun.tools.javac.Main.compile(Main.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess0(JavacCompiler.java:551)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:526)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:167)
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:678)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
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:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.ClassNotFoundException: org.netbeans.lib.editor.codetemplates.CodeTemplateCompletionProvider
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 45 more
我的依赖项
<!-- Common Scripting Language API (new) -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-csl-api</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Datasystems API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-loaders</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Dialogs API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-dialogs</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- File System API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-filesystems</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Lexer API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-lexer</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Lookup API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Nodes API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-nodes</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Text API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-text</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- UI Utilities API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-awt</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Utilities API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>${netbeans.version}</version>
</dependency>
<!-- Window System API -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-windows</artifactId>
<version>${netbeans.version}</version>
</dependency>
您可能在为平台工件生成maven的pom.xml文件时发现了错误。虽然org netbeans modules csl api jar包含对代码模板模块的模块依赖项(org.netbeans.modules.editor.codetemplates/1=1),但它不在已解析依赖项列表中。请针对提交问题https://netbeans.org/bugzilla组件:apisupport子组件:maven。
谢谢。
PS:解决方法确实是你尝试过但没有完成的路径。继续添加缺少的依赖项,直到满足注释处理器的运行时依赖项为止。
所需的依赖关系(对于NetBeans 7.3.1)为:
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-editor-codetemplates</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.modules</groupId>
<artifactId>org-netbeans-modules-editor-errorstripe</artifactId>
<version>${netbeans.version}</version>
</dependency>