【问题标题】:How do I set the Scala compiler to use a plugin when I build using Maven?使用 Maven 构建时,如何将 Scala 编译器设置为使用插件?
【发布时间】:2011-02-10 10:14:47
【问题描述】:

所以我有一个包含两个子模块的 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

修复它。

谢谢

【问题讨论】:

    标签: scala maven


    【解决方案1】:

    用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>
    

    【讨论】:

    • 可能是这样,但我是 Maven 新手。你知道 org_scala_tools_maven.BasicArtifact[] 是什么意思吗?
    • 谢谢,现在它发现它是需要的。不幸的是,它试图下载它。我怎么告诉它不要呢?
    猜你喜欢
    • 2018-06-02
    • 2017-03-18
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-20
    • 2016-08-10
    • 1970-01-01
    相关资源
    最近更新 更多