首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven android编译多个源目录

Maven android编译多个源目录
EN

Stack Overflow用户
提问于 2011-09-09 21:30:09
回答 1查看 676关注 0票数 1

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

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

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

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

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

我的pom.xml的相关部分

代码语言:javascript
复制
<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获得要编译的Mira源文件。但是mvn compile仍然只编译src/main/java中的源代码,而不是src/main/mira.

对于任何对mvn -X compile的输出感兴趣的人,这里提供了pastie

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-09 23:52:27

这个页面的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

编辑:

我自己试过了,这对我很有效(所谓“工作”,我的意思是插件被调用了--我的构建实际上失败了)。

代码语言:javascript
复制
<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>

使用以下输出:

代码语言:javascript
复制
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:

我不知道这个错误是什么意思,因为我不是米拉的用户。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7362378

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档