1

我已经使用这个原型创建了一个 maven android 项目。我想将mirah源文件集成到我的项目中。所以我将这里提到的插件添加到我的 pom.xml 中。我为插件设置了配置部分,将源目录指向 src/main/mirah。

但是当我运行mvn compile它时,它只会编译 src/main/java 中的源代码。我已经尝试运行它mvn -X compile来尝试调试问题,但我找不到与 mirah 或 mirah-maven-plugin 相关的任何内容。

它使用原型创建了两个项目 - project 和 project-it (tests) ,根目录中有一个 pom.xml ,project 和 project-it 目录中有一个 pom.xml 。我已经在根目录以及项目的 pom.xml 中尝试了上述配置。

我遇到了这个与使用build-helper 插件相关的问题,但我不知道它是否对我有帮助。因为我的mirah插件根本没有被调用。

这是做我想做的事情的正确方法吗?任何有关设置的帮助或有关如何解决此问题的指针将不胜感激。

我的 pom.xml 的相关位

<plugin>
   <groupId>org.mirah.maven</groupId>
   <artifactId>maven-mirah-plugin</artifactId>
   <version>1.0</version>
   <configuration>
       <sourceDirectory>src/main/mirah</sourceDirectory>
       <outputDirectory>target/classes</outputDirectory>
       <bytecode>true</bytecode>
       <verbose>false</verbose>
   </configuration>
   <executions>
      <execution>
         <phase>compile</phase>
         <goals><goal>compile</goal></goals>
      </execution>
   </executions>
</plugin>

根据下面的答案进行编辑。

我已经使用build-helper 插件添加了源目录,并且我可以mvn org.mirah.maven:maven-mirah-plugin:1.0:compile从下面的答案中获取要编译的 mirah 源。但mvn compile仍然只编译 src/main/java 而不是 src/main/mirah 中的源代码。

对于任何对mvn -X compile这里的输出感兴趣的人来说是paste

4

1 回答 1

2

这个页面https://github.com/calavera/maven-mirah-plugin#readme说 mirah 插件扩展了默认的编译器插件。所以这表明构建助手插件适用于多个源目录,如果它适用于默认编译器插件。

查看mirah plugin,您可能不需要指定sourceDirectoryoutputDirectory自己,因为您似乎正在使用默认值。

-X开关不会直接对 mirah 插件产生任何影响,因为它本身不进行任何跟踪(高于默认编译器插件所做的)。

无论如何,您能否显示您的-X输出以表明未调用 mirah 插件?

或者,您可以自己构建 mirah 插件并添加跟踪。它似乎不是一个复杂的插件。

当您尝试直接调用插件时会发生什么?例如

mvn org.mirah.maven:maven-mirah-plugin:1.0:compile

编辑:

我自己试过了,这对我有用(“工作”是指插件被调用——我的构建实际上失败了)。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>temp</groupId>
    <artifactId>temp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.mirah.maven</groupId>
                <artifactId>maven-mirah-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <bytecode>true</bytecode>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

有了这个输出:

D:\dev\workspaces\3.6\temp>mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - temp:temp:jar:0.0.1-SNAPSHOT
[INFO]    task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [mirah:compile {execution: default}]
[INFO] No sources to compile
Parsing...
  D:\dev\workspaces\3.6\temp\src\main\mirah/test.mirah
Inferring types...
* [Mirah::Typer] Learned local type under #<Mirah::AST::StaticScope:0xbc5245> : a = Type(int)

... ETC ...

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unknown error - Unknown Error (20047) - D:\dev\workspaces\3.6\temp\target\classes\D:

我不知道错误是什么意思,因为我不是 mirah 用户。

于 2011-09-09T15:52:26.883 回答