我使用这个 archetype 创建了一个 maven android 项目.我要整合mirah我的项目中的源文件。所以我添加了提到的插件 here到我的 pom.xml。我设置插件的配置部分以将源目录指向 src/main/mirah。
但是当我运行 mvn compile
时,它只编译 src/main/java 中的源代码。我已经尝试使用 mvn -X compile
运行它来尝试调试问题,但我在那里找不到与 mirah 或 mirah-maven-plugin 相关的任何内容。
它使用原型(prototype)创建了两个项目 - project 和 project-it (tests) ,在根目录中有一个 pom.xml,在 project 和 project-it 目录中有一个 pom.xml。我已经在根目录和项目的 pom.xml 中尝试了上述配置。
我遇到过与使用 build-helper plugin 有关的问题但我不知道这对我的情况是否有帮助。因为我的 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 plugin 添加了源目录并且我能够使用 mvn org.mirah.maven:maven-mirah-plugin:1.0:compile
从下面的答案中编译 mirah 源代码。但是 mvn compile
仍然只编译 src/main/java 而不是 src/main/mirah 中的源代码。
对于任何对 mvn -X compile
的输出感兴趣的人,这里是 pastie .
最佳答案
本页https://github.com/calavera/maven-mirah-plugin#readme说 mirah 插件扩展了默认的编译器插件。因此,这表明构建助手插件适用于多个源目录,如果它适用于默认编译器插件的话。
查看 mirah plugin ,您可能不需要自己指定 sourceDirectory
和 outputDirectory
,因为看起来您使用的是默认值。
-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 用户,不知道错误是什么意思。
关于java - Maven android 编译多个源码目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7362378/