How to add Maven to an existing IntelliJ Android project - java

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

Related

Combining a maven project with a java project

Currently, I have a maven project that has a server running (using Jersey REST API). I also have a java project, I need to move all the contents of the java project into the maven project. The maven project is a subset of the java project. However, the maven project only displays the parts of the java project. However, I want a project that allows me to use maven and displays all of the other details from the java project.
I would've copied and pasted however I'm using git so I want to also preserve history.
I was thinking it would be easier to nest the maven project inside the java project but I don't know if that's possible.
Here's a picture of my package explorer to help explain everything.
Package explorer showing the maven project being a subset of the java project.
What I've tried is converting the java project into a maven project and then updating the pom.xml but then it doesn't link to the web.xml. Also, it tries to run the server with the name of the project name TeamProject. When infact it should run the url with the name client_server
I was considering just copying and pasting all the code into the maven project (from the Teamproject java project).
Actually nesting the java project inside the Maven project makes more sense, as it is the purpose of Maven to handle a project lifecycle. (also by default Maven will look for sources in the src/ folder which should ease the task of putting your Java project inside Maven's hands)
There are several possibilities I would see:
Copy your java project in the src/ of your client project and update maven accordingly (within the pom.xml)
Make your Java project a Maven project and aggregate the two projects in a parent pom (see Multi module maven project example)
Make your Java project a Maven project, and decide of a "Master" project between it and the client and compose one with the other (not sure that's a great solution)
Nesting your Maven project inside the Java project would not be so great because Maven could only handle the client and not your Java project, and then you'd miss on numerous functionalities offered by Maven (just look at how simple it is to get dependencies compared to downloading a jar and including it on the build path manually)

How Do I Import a Non-Android Eclipse Maven Project into Android Studio?

I am starting at a disadvantage as I know neither Eclipse, Gradle or Android Studio. As such, I may not be using the correct terminology for everything, but I'll give it a shot. My ultimate goal is to get a working Eclipse-based Android app imported into Android Studio and hand it back to the Android developer. This question is about a problem I encountered on the way.
I have successfully imported the main Android project into AS. Now I'm trying to pull in another project it depends upon as a module. The dependency is a Maven project. It has a pom.xml, a .project and a .classpath. It's not an Android project, so there's no AndroidManifest.xml. It has a src but no res folder. I want this project to be a module rather than an external dependency as the developer will modify the source code on occasion.
The problem is that AS refuses to accept the project as an importable module. The Add Module dialog, when pointed to the project's root directory, continues to warn that I haven't yet selected a valid Android Eclipse or Gradle project. The Next button stays grayed-out. I agree that this is neither an Android-specific nor a Gradle project, but I have read here that IntelliJ IDEA will import such projects. It appears that AS will not.
There are several other non-Android Eclipse projects that also won't import as modules in the same way. These include ordinary Maven and ant-based libraries.
How do I accomplish this? The GUI seems out to thwart me. If I get down to the Gradle XML level, can I do it and will the modules show up normally in the GUI? Do I have to go back to Eclipse and convert these to Gradle projects first?
Thanks in advance.

How do I migrate an Eclipse GAE project to Maven such that it won't be tied to Eclipse?

I have an open source Eclipse Google App Engine project (it's called LastCalc and it's open source, you can find it here, created using the GAE Eclipse plugin.
The problem is that several months ago I switched IDEs to IntelliJ IDEA. Since most of my projects were Maven-based this wasn't an issue, but LastCalc was stubbornly tied to Eclipse.
I'm hoping that someone can suggest an easy way to migrate this project to Maven such that it will work nicely in both IDEA and Eclipse.
We released the app engine maven plugin and a gustbook sample with that plugin. I don't think the manual migration is very difficult. You can create a directory structure similar to our guestbook sample and copy your source and resource files. Dependency might be a bit cumbersome, so maybe you can try the 'Convert to Maven Project' functionality of the newer version of m2eclipse.

Choosing Netbeans project template or maven's project template

I'm little confused because of too many options when we take anything in java. I want to create a web application in java. whether i have create web application from 'java web' or 'maven' by creating new project in netbeans. I may use some archetypes in my future, but whether maven project has full IDE support from netbeans
I've been using Maven projects in NB 7 without a problem.

can eclipse plugin project depend on java project

I have an eclipse plugin project which dependes on java project in my eclipse. usually what I did is export the project as jar and use it as-is in the plugin. but this requires manual work. can I have a reference from my plugin projct to a java project that will be both compile-time and run-time dependency ?
I saw a similar question, but not exactly the same.
I think, the closest thing to this is to create a jar file from the referenced project, and import it to the projects repository. But thats quite hard to manage for a currently developed project.
On the other hand, isn't it possible to simply convert the Java project into a plug-in permanently? If the other user does not use OSGi/Eclipse, he/she will see only a manifest/manifest.mf file (and possibly a plugin.xml) next to the java project specific stuff, so this would not disturb them, but would help you.

Categories

Resources