当我使用 Maven 构建时,如何设置 Scala 编译器使用插件?
所以我有一个包含两个子模块的 Maven 项目。第一个是编译器插件本身,它按照我的预期进行编译。
第二个子模块是一些示例代码,我想使用之前构建的编译器插件进行编译。
所以我在 pom 文件中有这样的内容:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDir>.</sourceDir>
<!--jvmArgs>
<jvmArg>-Xms64m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs-->
<args>
<arg>-Xplugin:../plugin/target/plugin-1.0-SNAPSHOT.jar</arg>
</args>
</configuration>
</plugin>
根据我能读到的内容,应该为编译器提供正确的参数,但它似乎根本没有做任何事情。
编辑:按照建议,我尝试使用compilerPlugins标签,所以相关区域变成:
<configuration>
<sourceDir>.</sourceDir>
<compilerPlugins>
<compilerPlugin>
<groupId>*groupid*</groupId>
<artifactId>plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
这确实有效,不幸的是它现在产生了这个错误:
无法找到资源存储库 scala-tools.org (http://scala-tools.org/repo-releases) 中的 'groupid:plugin:jar:1.0-SNAPSHOT'
这是很容易理解的,因为它不是那里。
我尝试将其作为依赖项添加到依赖项列表中,但这并没有改变任何内容。
最终编辑:
执行:
mvn clean install
修复它。
谢谢
So I have a Maven project with two submodules. The first is the compiler plugin itself, which gets compiled as I expect it to.
The second submodule is some example code that I want to compiler with the previously built compiler plugin.
So I have this in the pom file:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDir>.</sourceDir>
<!--jvmArgs>
<jvmArg>-Xms64m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs-->
<args>
<arg>-Xplugin:../plugin/target/plugin-1.0-SNAPSHOT.jar</arg>
</args>
</configuration>
</plugin>
Which based on what I could read about it, should give the right arguments to the compiler, but it doesn't seem to do anything at all.
Edit: As suggested, I tried to use the compilerPlugins tag, so the relevant area became:
<configuration>
<sourceDir>.</sourceDir>
<compilerPlugins>
<compilerPlugin>
<groupId>*groupid*</groupId>
<artifactId>plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
And that did indeed work, unfortunately it now produces this error:
Unable to find resource 'groupid:plugin:jar:1.0-SNAPSHOT' in repository scala-tools.org (http://scala-tools.org/repo-releases)
Which is quite understandable, as it isn't there.
I tried to add it as a dependency to the dependencies list, but that didn't change anything.
final edit:
executing:
mvn clean install
fixed it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用compilerPlugin配置来设置工件不可行吗?
http://scala-tools.org/mvnsites/maven -scala-plugin/compile-mojo.html#compilerPlugins
更新:它基本上是一个类似依赖项的工件。您将在其中添加编译器插件作为工件:
Doesn't it work using the compilerPlugin configuration to set the artifact?
http://scala-tools.org/mvnsites/maven-scala-plugin/compile-mojo.html#compilerPlugins
Update: It's basically an artifact like a dependency. You will add your compiler plugin as artifact inside it: