Support 'android' as well as 'com.google.android' as group ids. #186
Conversation
Looks good but I can't merge this without an integration test. Please add. |
The maven android sdk deployer by default uses 'android' as the group id instead of com.google.android. I believe google with Gradle is starting to move toward the com.google.android groupID but for legacy projects the 'android' groupID still needs to be supported otherwise projects can't be configured.
Will work on the integration test. I'll take a look at the existing tests for examples. |
@kingargyle thanks, much appreciated. Although you may have some problems writing test if groupId "android" artefacts aren't in Maven Central. |
Yeah, that is another problem. The lookup always seems to go to the remote repository, and doesn't appear to look in the local repository for items. It should try and check the local repository first, and then central. Haven't looked into it too much for why this currently happens. |
I think it is checking the local repository first, that is the default behaviour. It might just be running as a different user and not using your personal $HOME/.m2/repository directory. But remember, this integration tests run in Travis and other environments so we can't always guarantee we'll be able to run the maven-android-sdk-deployer. |
Yeah, will probably need to mock some things out to make it platform neutral. Will be a bit before I can get back to this |
This looks like a fix for #181 |
I think the best solution for the problems with absent maven-android-sdk-deployer "android" groupId artefacts is to add the maven-android-sdk-deployer to the build process, both in the README and in the .travis.yml build descriptor. |
That should get around the problem. |
Another alternative is to import the maven-sdk-deployer into m2e-android directly so, it encounters an android group id, it automatically imports the relevant SDK binary into you local repo |
Even with this fix, the code still errors with the following error message:
Looks as though m2e-android tries to resolve the dependencies remotely even though they're only available locally. |
OK I fixed the above but there is a further problem: the Android API dependencies deployed by the Android Maven SDK Deployer do not contain references to the other APIs (httpcomponents, etc) bundled with the Android Platform. This causes the following tests to fail: testConfigureAddsPlatformProvidedDependenciesToTestRunnerClasspath Maybe these aren't important although this is annoying. |
BTW do you think the artifacts deployed by the Deployer should contain these references? |
The HTTPComponents from Apache are deprecated anyways. Most people will replace it with their own Http Client, or use the URLConnection items, which is where Android is trying to push people. |
@WonderCsabo if the old dependencies published by Google had references to platform provided dependencies like common-logging or httpclient (its not just httpclient @kingargyle) the new ones should too I feel. At the moment I've hacked a fix for this, but maybe we should raise this with the upstream project? |
Rebased into commit 2367ded |
By "the upstream project", you mean the |
We usually have to end up excluding the commons-logging in our builds, because of proguard warnings if we use the com.google.android versions from maven central. I believe the maven sdk deployer doesn't specifically include them because those libraries are provided in the android jar that get deployed. Either way, we'll just specifically exclude the dependencies that are not necessary in our particular builds. |
CI fixed. This update should now be available from the snapshot update site: http://rgladwell.github.io/m2e-android/updates/master/ If you're using m2e-android commercially or you'd like to see more frequent releases please consider crowdfunding me through my Patreon profile. |
@kingargyle I'm confused, you I thought commons-logging was provided as part of the Android platform and should only be used as a provided-scope dependency in Android projects? You shouldn't need to ProGuard? |
If you specifically bring in the Apache Commons HTTP dependency, it'll also bring in the apache-commons dependency as well. We had to specifically mark the apache commons as provided in our build so it wouldn't get included. Anyways, just something we have to keep in mind. Personally I think the android maven sdk deployer is correct in the way it is handling it. As the android.jar that is deployed typically already has all those dependency packages included in the jar. |
@kingargyle why would you specifically include the Commons HTTP dependency? Can I confirm, the Android platform dependencies added by the Android Maven SDK Deployer include platform-provided dependencies like HTTP client? |
The reason we include the HTTP Client specifically (which has it's own dependency on HTTP Commons Logging), is that we needed bug fixes and other items that are in the newer versions of HTTP Client. The version included in the android.jar is several versions behind, and isn't being updated any more. Only the stubs are included in the android.jar, so yes you are correct that the HTTP Client dependency is needed if you are going to run unit tests. Robolectric doesn't need it because it intercepts the DefaultClient constructor and provides a shadow for it. I opened the android.jar that is deployed by android maven adk deployer, and it contains both the apache http client, and the apache commons classes. This is why you can compile and write code, but need to use something like Robolectric to run unit tests natively. What it doesn't do is specifically put additional dependencies, when it is deploying the jar to the local maven repository. It is just using the file-deploy goal of the maven deploy plugin. |
@kingargyle so does the HTTP client bundled in your APK override the one provided on Android devices? Thanks for checking that, sounds like we won't need the code that filters out the Android platform-provided dependencies from the Eclipse classpath in future. I always thought it was a bit odd Google included things like httpclient in the first place. |
@kingargyle BTW can you please check if the latest snapshot code is working as you expect? |
Yes, the one bundled in your APK takes precedence over the one bundled with Android itself. Latest snapshot is working, as my own project we use the android groupid instead of com.google.android. |
The maven android sdk deployer by default uses 'android' as the group id instead
of com.google.android. I believe google with Gradle is starting to move toward
the com.google.android groupID but for legacy projects the 'android' groupID still
needs to be supported otherwise projects can't be configured.