johannilsson / android-actionbar

DEPRECATED Android Action Bar Implementation
1.3k stars 564 forks source link

Maven #20

Closed lvillani closed 13 years ago

lvillani commented 13 years ago

This should make android-actionbar usable as Maven dependency.

johannilsson commented 13 years ago

Hi, thank you. Is there a reason why we need to change the Android version to 2.1 for this to work? I would prefer to actually increase the version instead.

I'm not very familiar with Maven, but is it possible to package a library project (including layouts etc) as something that can be distributed via a maven repo?

lvillani commented 13 years ago

Regarding API Level 8 -> 7: there's no real reason other than the fact I am working on a product which is targeted at Android >= 2.1 devices.

As for Maven: we are using maven-android-plugin (http://code.google.com/p/maven-android-plugin/) which is able to pack a library project into an "APKLib" which can be then referenced from an Android project (managed by Maven).

There are still rough edges in maven-android-plugin but I'm testing some patches which should improve APKLib handling.

rtyley commented 13 years ago

I think it's cool to mavenise android-actionbar - also, ultimately, it would be great for the artifacts to be published to Maven Central. The best, easiest way to do this is to use the awesome service provided by Sonatype for open-source projects. See here:

https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide

I've been though this process, there's a few JIRA tickets to open initially, but once you've got yourself setup with a password and a GPG key, you can publish at will to Maven Central using their staging repository at https://oss.sonatype.org/ - it works pretty well, and ultimately will minimize the amount of effort required by people to use your project.

Of course, the amount of effort to use android-actionbar at the moment already is pretty minimal - just copy the single class and some of the resource files over with minor editing - but even then, maven makes some things easier - versioning for instance, so that people can easily upgrade to newer versions by changing a version number in their pom, rather than doing a copy and paste of the entire class file.

JakeWharton commented 13 years ago

I think you are confusing the versions for the target SDK and the minimum SDK. The minSdkVersion already allows use all the way back to Android 1.5. The target should be set to the newest version so you are always compiling against the latest builds.

Also, as a Maven user and Android developer the inclusion of a pom.xml and the deployment of artifacts to a central repository would be a much welcome change.

johannilsson commented 13 years ago

This sounds good. I guess I can merge this and figure out how to push it to a repository later on. I just need to read up on maven a bit first.

johannilsson commented 13 years ago

Hi, I've merged this now. Still need to figure out how to properly release using maven though. But I've managed to deploy an artifact to a repository here, http://markupartist.com/repository/. Please test it and see how it works.

JakeWharton commented 13 years ago

You are ultimately going to run into problems trying to do automated releases from a Git repository with your pom.xml in a subdirectory. During the automated release cycle, Maven re-clones your repository and performs operations on its clone, rather than your current folder. Since it does not know to look into the subdirectory, it will not find a pom.xml in the root and fail.

There are two easy solutions for how to fix this though.

I would probably prefer the latter since it then allows you to also add a submodule for the example so it gets versioned along with the library. I'll try to get a pull request in this week for the latter with some simple instructions to go along with it.

Moving to Maven, especially for Android, has a bit of a learning curve but once you have the whole process running smoothly it's quite a time-saver.

rtyley commented 13 years ago

Incidentally, the maven-android-plugin has added support for Library projects (like what android-actionbar is) in 2.9.0-beta-1 - prob worth incorporating this.

http://code.google.com/p/maven-android-plugin/wiki/ApkLib

johannilsson commented 13 years ago

@JakeWharton Thanks for the clarification, I kind of suspected that. I tried to add the distributionManagement and scm elements based on your sherlock project but it failed halfway through the process. I'm also a bit nervous about automating things I don't really understand but I clearly see the benefits of it and guess I will learn over time. I also thinks that the latter suggestions sounds like the best option. Looking forward to that pull request.

@rtyley It's currently built as a apklib, seems to work fine. Haven't figured out how to easily add such a project yet with eclipse yet though.

johannilsson commented 13 years ago

FYI, not sure if it's me doing something wrong, but I could not build the example project when depending on the action bar widget.

It seems like there's a problem when referencing attributes on the widget from the layout like app:title="@string/some_title". I filed a bug at the maven-android-plugin issue tracker for it, http://code.google.com/p/maven-android-plugin/issues/detail?id=143.