Maven android编译多个源目录

时间:2011-09-09 13:30:09

标签: java android maven maven-3 mirah

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

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

使用原型创建了两个项目 - project和project-it(tests),根目录中有一个pom.xml,项目和项目目录中有一个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

1 个答案:

答案 0 :(得分:2)

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

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

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

您是否可以显示-X输出以显示未调用mirah插件?

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

尝试直接调用插件时会发生什么? E.g。

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