所以我有一个包含两个子模块的 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>
Run Code Online (Sandbox Code Playgroud)
根据我所读到的内容,应该为编译器提供正确的参数,但它似乎根本没有做任何事情。
编辑:按照建议,我尝试使用compilerPlugins标签,所以相关区域变成:
<configuration>
<sourceDir>.</sourceDir>
<compilerPlugins>
<compilerPlugin>
<groupId>*groupid*</groupId>
<artifactId>plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这确实有效,不幸的是它现在产生了这个错误:
无法找到资源“ groupid” :plugin:jar:1.0-SNAPSHOT”
这是可以理解的,因为它不存在。
我尝试将其作为依赖项添加到依赖项列表中,但这并没有改变任何内容。
最终编辑:
执行:
mvn clean install
Run Code Online (Sandbox Code Playgroud)
修复。
谢谢
使用compilerPlugin配置来设置工件不可行吗?
http://scala-tools.org/mvnsites/maven-scala-plugin/compile-mojo.html#compilerPlugins
更新:它基本上是一个像依赖项一样的工件。您将在其中添加编译器插件作为工件:
<compilerPlugins>
<compilerPlugin>
<groupId>_your plugins groupId_</groupId>
<artifactId>plugin</artifactId>
<version>1.0-SNAPSHOT</groupId>
</compilerPlugin>
</compilerPlugins>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
481 次 |
最近记录: |