有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Maven 安卓编译多个源目录

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

但是当我运行mvn compile时,它只编译src/main/java中的源代码。我试着用mvn -X compile运行它来调试这个问题,但是我找不到任何与mirah或mirahmaven插件相关的东西

它使用原型创建了两个项目——项目和项目it(测试),其中有一个pom。根目录中的xml以及pom。项目和项目it目录中的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) 个答案

  1. # 1 楼答案

    这个页面说mirah插件扩展了默认的编译器插件。因此,如果build helper插件适用于默认的编译器插件,那么它将适用于多个源目录

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