How to add Maven to an existing IntelliJ Android project

I've been doing some research on adding Maven to an existing Android project and I'm struggling to see how this works. I've used Maven once at work on a web based project with Netbeans, but for this project I'm looking to use IntelliJ. I can create a new "Maven Module", but I already have an Android project so I'm not entirely sure that's the route I should be taking.

I found this post which does provide some detail, but not a step-by-step windows integration guide (at least that I'm seeing).

Is it possible for me to use Maven within an Android project?

Edit: I'm looking to do this within a Windows environment


To answer your question in the last sentence: Yes, you can use Maven to build an Android project.

You should use the maven-android-plugin in your Maven project. The best place to get started is https://code.google.com/p/maven-android-plugin/wiki/GettingStarted. Need to read up a bit, but definitely worth the effort.

If I have existing IDE specific Android project that you would like to switch to Maven, instead of trying to "add Maven support to an existing IntelliJ project", I would:

  • Create a new Maven based project using an appropriate archetype https://github.com/akquinet/android-archetypes

  • Copy existing source/resources to the Maven project directories.

  • If done correctly, you can open this (Android) Maven project (pom.xml) in IntelliJ and use it like an Android project (including GUI editor). IntelliJ automatically generates an IntelliJ project from Maven's pom.xml and detects the Android facet.

    This way, your project also stays IDE agnostic - you can do everything (build/test/deploy) from command line as well - how Maven projects should be IMHO. :D

    链接地址: http://www.djcxy.com/p/57502.html

    上一篇: 使用Gradle和R项目

    下一篇: 如何将Maven添加到现有的IntelliJ Android项目中