Maven:将Android项目从Ant迁移到Maven



我启动了一个Android项目,默认情况下它是用ANT构建的,我正在尝试将其升级到Maven,这样我就可以摆脱Android SDK的编译时问题,以及库导入和管理的方便性。我遇到的问题是:

1( 如何修改build.xml以指示其使用maven。2( Maven抱怨文件夹结构错误。

这是我的build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="myapp" default="help">
 <property file="local.properties"/>
    <property file="ant.properties"/>
<property environment="env"/>
    <condition property="sdk.dir" value="${env.ANDROID_HOME}">
        <isset property="env.ANDROID_HOME"/>
    </condition>
// and more

所以我想我必须修改ant.properties属性,我该如何建议使用Maven??

这是我粘贴在项目的Parent目录中的POM.xml,但当我尝试运行mvn-compile时,我得到了以下错误:

Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:4.0.0-rc.2:generate-sources (default-generate-sources) on project gs-maven-android:
[ERROR] 
[ERROR] Found files or folders in non-standard locations in the project!
[ERROR] ....This might be a side-effect of a migration to Android Maven Plugin 4+.
[ERROR] ....Please observe the warnings for specific files and folders above.
[ERROR] ....Ideally you should restructure your project.
[ERROR] ....Alternatively add explicit configuration overrides for files or folders.
[ERROR] ....Finally you could set failOnNonStandardStructure to false, potentially resulting in other failures.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

最后,这里是POM.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.hello</groupId>
    <artifactId>MyAPP</artifactId>
    <version>1.0</version>
    <packaging>apk</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>4.0.0-rc.2</version>
                <configuration>
                    <sdk>
                        <platform>20</platform>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

那么我在这里做错了什么?任何帮助都会很好。我在Ubuntu Linux上使用Intellij Idea。谢谢

请更新到完整版本,然后更新帖子中的错误消息。最新版本是4.3.0。

该警告是关于位于非标准文件夹中的源代码和其他源的。您应该使用标准结构。完整版本将显示错误消息,其中包含所有内容的详细信息。

相关内容

  • 没有找到相关文章

最新更新