How do I set the Scala compiler to use a plugin when I build using Maven?
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
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:
<compilerPlugins>
<compilerPlugin>
<groupId>_your plugins groupId_</groupId>
<artifactId>plugin</artifactId>
<version>1.0-SNAPSHOT</groupId>
</compilerPlugin>
</compilerPlugins>
精彩评论