My Face

Olรก! I'm Luis

I'm a software developer building mobile native apps and writing about what I learn.

Publishing your first android library!

15 September, 2020

Publishing a library you develop is a journey on its own. It can be overwhelming, especially if you are targeting Android. There is a lot of documentation out here, but I could not find one that would go end to end with it. So I wrote this post!

This came about because I released my first open source library: Kroclin! It is a snapshot testing library written in Kotlin, to help out writing less code in your tests. Check it out and give it a star if would like. Now, let me tell you about the journey to release it!

Sonatype provides a guide for OSS repository hosting and another one for releasing your deployment that I read, but they could be more helpful. Everything you need to know is there, it just takes several readings and lots of googling to grok it. Here are the steps you need to go through:

First, create a Sonatype JIRA account if you don't have one already.

Then create a new project issue. Make sure to click this link, since they require that you use the template. In the issue body, write that you want to claim the domain that matches the library groupId. In the case of my library, the groupId is dev.luisramos.kroclin and I claimed dev.luisramos.*. Here is my JIRA ticket as an example.

I picked up from reading other issues that you only need to go through this process once, if you request a wildcard `groupId`. Other libraries released under the same `groupId` don't require a new project ticket to be created.

Note that you could also claim the groupId that matches your project hosting, for example, io.github.orgmir if that's where your project lives.

After you have opened a new project ticket, you need to prove that you own the domain you claimed. You can either:

  1. Add a TXT record to your DNS referencing the url to the JIRA ticket you created (fastest)
  2. Setup a redirect to your github page

I went with the first option, and since every DNS provider differs I won't go into specifics. Some googling on how to add a TXT record for your DNS provider should get you there.

NOTE: You will need to submit the full URL for the issue, so in my case the content for the TXT record was https://issues.sonatype.org/browse/OSSRH-60527.

I went ahead and added a comment on the ticket with the output of dig -t TXT luisramos.dev, just to show that it was working. Don't know if it made a difference ๐Ÿ˜…

After doing the proof of domain ownership, you will need to wait for Sonatype to reply to your ticket. They will let you know once the repository on their end is ready to receive artifacts. Don't actually upload anything until they give you the OK, your artifacts will just end up in a generic catch-all repository.

After they reply, go ahead and upload your first artifact. You can copy my gradle-mvn-push.gradle script and run ./gradlew clean build uploadArchives (don't worry, I also copied it from someone else). You could also use a plugin like vanniktech/gradle-maven-publish-plugin.

Once the upload is done, go ahead and log in to https://oss.sonatype.org using your Sonatype JIRA account.

Nexus Repository Manager

Select Staging Repositories on the side bar, and you should see a list with the repository for your library. Select the repo, and press Close on the top bar. This will perform some validation on Sonatype's side, and once the status updates and the repository is tagged as closed, select the repository again and press Release.

If you use a plugin, the upload step will probably try to close and release the staging repository. Loggin in to Nexus Repository Manager should only be needed when you are releasing for the first time, or if you use a script like me.

You can now update on your JIRA ticket that the repository has been released. This will let Sonatype know, and they will trigger a sync with maven central, so your library can show when searching in search.maven.org. This step should is also only needed the first time you are releasing.

And that's it! It might take a couple of hours for the sync to happen, but congratulations! You have released a library onto the world! What a trip it was ๐Ÿš€

Ler - An RSS Aggregator for Android!

20 March, 2020

I have been working on a RSS aggregator app called Ler. Its available for Android, and you should give it a try! It is the first app I design, develop and publish all by myself, so I am pretty proud of that!

Get it on Google Play

I know what you are thinking, another RSS feed app? Aren't there billions of them? Well, yes. But this one is mine. And I have plans. Big plans! Let me tell you how it came to be, and what I want to do with it.

Twitter is a time sink

I spend too much time on twitter. I checked my phone usage settings for apps, and twitter is always number one on the list, toppling YouTube (!!) and WhatsApp. I though I watched a lot of Youtube, but aparently, on a very boring day, I accumulated 4 hours of twitter usage...

So I looked into Googles digital wellbeing app, and turned on a 30 minute timeout for Twitter. And it works! Some days, I don't even reach the timeout. Unfortunatly, this also meant that a lot of the blogs I read wouldn't reach me as well.

And there you have it. I took the time I was wasting and built this app!

Ler

The app name is the portuguese word for reading. I did a search and it seems nobody claimed it, so why not? The main features that I have built so far:

  • You can subscribe to RSS feeds (crazy I know). You can manually type in a website adress, or you can share from the browser to the app!
  • You can filter out articles that you already read, or just show articles from one feed.
  • You can swipe an article to toggle it read, or mark all articles in a feed at once!
  • Feeds will be checked for updates every hour automagically.

Articles currently open in the browser. I toyed with the idea of having a built in reader, but that seemed overkill for what I wanted to do. I already used the browser to do most of my reading anyway.

I am pretty proud of how it turned out, despite not being great at UI design, I kept it simple and it does the job! I have been using it for the past couple of weeks, and I think I impressed myself by actually using it instead of defaulting to Twitter as a time killer.

Open so everyone can read it

Not only am I using this app to avoid using twitter all the time, I will also use it as a showcase project. Hence, my plan in the next weeks is to write a bunch of tests, clean up the folder structure, and open source it.

So far, I have not worked in an app that had their source open, so most often when talking about my work I can't provide examples. I applied all my knowledge and tried to build the simples app I could, while still being a good example of how I would build an app.

My plan is to also write about android development, while using the app as an example. I made some architecture choices that I can talk about, since I haven't found a lot of written examples online.

Please give it a spin, and let me know what you think! You can tweet at me or send me an email. I have a little roadmap with more features, but let me know if you want a particular feature added, and I will add it to the list!

My new blog! - Creating a Gatsby website

17 March, 2020

Welcome to my new blog! Hope you enjoy it, I have spent the last couple of weeks building it. Now that it is done, I can finally start writing about stuff!

I kinda rebuilt it because I wanted to write about building it...

So let me tell you how it works, what I learned, and how easy it is to do it!

Tech stack

To be upfront about it, this blog is built using Gatsby, and deployed using Github Actions to a Digital Ocean droplet. And I am very happy with it. This entire website is open source, so if you wanna check the code go ahead!

One day I was reading some blog posts from Tania Rascia and this post made me look into Gatsby. In it she migrated her wordpress blog to a Gatsby website that she built from a pretty bare bones template. I have been thinking of revamping my blog again, since the last one was more than a year ago. Pairing that with my interest with this new JAMStack thing, I just got excited and started looking through the docs!

After building this website, I really enjoyed working with the plugin system and I loved that it used React and Graphql.

Getting started

Following Tania's footsteps, I installed the gatsby-cli and created a website using the gatsby-advanced-starter. Turns out, that was totally overkill for me, and most of the things there overwhelmed me. So I tried again running gatsby new luisramos.dev and slowly added the plugins I needed as I went along.

Starting with the empty project, the first thing I did was setup Tailwind CSS. I am not very good in terms of design skills, and playing around with CSS is fun but can also become a huge waste of time. Tailwind fits nicelly into the "just make a component" React world, and paired with a fantastic documentation page, it is very easy to work with. You can quickly create your styles using the existing classes, and when it you start duplicating a lot, you move everything to a component! ๐Ÿ‘

Setting up Tailwind with Gatsby was as easy as adding the plugin gatsby-plugin-postcss to gatsby configuration, adding a postcss.config.js requiring the Tailwind library, and adding the Tailwind css imports to the global.css file.

I am very impressed with the plugin system. Anything you need, and you bet there is a plugin that does it! I wanted a RSS feed with all my posts, there's a plugin for that: gatsby-plugin-feed. I want my posts to be in markdown, there's a plugin for that: gatsby-transformer-remark. I wanted syntax highlighting for my code snippets, there's even a plugin for the plugin: gatsby-remark-prismjs! Overall, very wonderful to work with.

This plugin system even got me wanting to build more websites!

React+Graphql

Another feature I enjoyed was the React and Graphql support. In the beggining it felt very overkill to have a graphql query everywhere, but the more I read the documentation, the more it made sense to me.

I have enough experience with React that I could jump straight into this new website building my layout. After I had build the header/footer/nav combo, I started thinking about the main page, and I decided that I wanted the latest three posts there. So when you land, you can immediatly read some stuff.

To do this, you write a graphql query in your React page, name it pageQuery and export it. Then, Gatsby will take the data generated from that query and feed it to the component.

The whole experience around this was incredible: I played around with the graphql browser until I had the data I wanted, I pasted the query into the page component, and like magic the data was there! Graphql is pretty sweet.

After that, I added some code to gatsby-node.js so it would create a page for all of my posts. It uses a template, so I don't need to create a component for each post manually. After that, I added a contact and about pages, an RSS feed, some more styling and a bit of content. Sooner than I was expecting, I had a website ready to be deployed!

Deployment via Github Actions

My previous blog was hosted on the same Digital Ocean droplet that this one is. I have this one box that I use to play around with several things, so since I am already paying for it, and I don't drive a lot of traffic, I planned the same for this blog.

The deployment steps to get this into the server are:

  • Run gatsby build to get the static version of the website
  • Upload the generated folder to the server, preferebly using rsync

So I shopped around a bit, and I am impressed by the amount of Github actions already available. I created a workflow that checkouts my code, runs the build and uploads the website to my server in less than half an hour. And it caches the ~/.npm folder, so it all runs in 2 mins on CI.

Yay Gatsby

I am very happy with the current setup. This website already has pulled this post out of me, so lets see if it makes me write more! Hope you enjoyed this write up as much as I have enjoyed building the site.

If you liked this post, or if you just wanna send me some feedback, send me a tweet.

As a final note, I wrote this post in a very cool markdown editor, Typora. It is free during beta, so give it a try!