Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Android-compliant builds #58

Merged
merged 1 commit into from
Sep 5, 2017
Merged

Add support for Android-compliant builds #58

merged 1 commit into from
Sep 5, 2017

Conversation

eburke56
Copy link
Contributor

It turns out that Android does not support having spaces in method names. As a result, Android instrumentation tests fail to run due to a runtime failure with the backtick versions of the methods in Kluent.

I moved the backtick code into separate files. I also made the code more uniform in that the camelCase methods have the actual code, where the backtick methods simply forward to the camelCase methods.

If you set the "ANDROID" property on the project, it will exclude the backtick files. When publishing, it will name the artifact "kluent-android".

For Android builds: ./gradlew -PANDROID assemble

I ensured that all unit tests run with and without the ANDROID property. I also verified that if I don't exclude the backtick tests, but I do exclude the backtick source, that the tests do in fact fail.

I also tested publishing to maven local and using the artifact in my Android projects. Everything works as expected.

…sions) using the ANDROID project property.
@MarkusAmshove
Copy link
Owner

Hi @eburke56 ,

wow! Thank you for figuring this out and making the huge step to actually get it working! I'm impressed!

It'll take me some days to look over it and try it out. Thank you alot!

@eburke56
Copy link
Contributor Author

You're welcome! I love the library you built here -- makes Kotlin tests extremely readable. Let me know if you need any updates.

@MarkusAmshove
Copy link
Owner

MarkusAmshove commented Sep 1, 2017

It works really well, thank you :-)

I'll go on and test the rest on Tuesday and push it to bintray by then.

Is using the DateTime API fine for Android? I thought they have older APIs on Android.

Also do you have any tip or experience on how to set up a reliant Android build on Travis or somewhere else? It would be helpful for future features to know when we break some kind of Android constraint :-)
Maybe there is something we can do with gradle to have it compile against the Android target and run the tests there

@eburke56
Copy link
Contributor Author

eburke56 commented Sep 1, 2017

RE: DateTime APIs, since it's Java 8, we can use it on Android. However, you should probably note that in the documentation so that folks using Java 7 don't get bit by it. That said, anyone using Kotlin on Android is probably using Java 8. :)

I have never set up Travis, but I do know some people who have done it. I will reach out to them and see what they know.

To run the tests on Android, you can try using Robolectric and run unit tests as normal. You would just need to choose the Robolectric test runner instead of the standard JUnit runner. That might uncover these issues. If not, you can create an androidTest directory which you then would run inside an emulator or on device, but that's harder to automate.

@MarkusAmshove MarkusAmshove merged commit 3913e09 into MarkusAmshove:master Sep 5, 2017
@MarkusAmshove
Copy link
Owner

It works as expected, thank you very much!

I've already published the Android version to bintray:

https://bintray.com/markusamshove/maven/Kluent-Android

At the moment it is awaiting approval from bintray to include it in jcenter, so to use it you have to include my maven repository at bintray at the moment:

repositories { maven { url "https://dl.bintray.com/markusamshove/maven" } }

once the package is approved I'll update the docs according to it, thank you very much!

Do you want to spread the word about Android support, on reddit for example? If not then I'd like to do that once it's approved :-)

@eburke56
Copy link
Contributor Author

eburke56 commented Sep 5, 2017

Sure, I'll post to reddit -- let me know to which you'd like me to post.

Thanks for approving this so quickly!

@MarkusAmshove
Copy link
Owner

It is now available in jcenter and working on my local builds.

I was thinking about the Kotlin subreddit :-P

@eburke56
Copy link
Contributor Author

eburke56 commented Sep 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants