Monday, November 10, 2014

Setting up Android development environment with DevAssistant

If you have ever tried to set up your Eclipse IDE for Android development, you will probably agree with me that it is a tedious job. You need to:
  • install ADT plugin, but first you need to tell Eclipse about the 3rd party repository from where to install it
  • restart Eclipse
  • download SDK Tools and tell Eclipse where to find it
  • select additional Android SDK packages to install in SDK Manager
The process doesn't sound like a lot of fun, if you ask me. Of course there are other options. For example Google is working on IntelliJ IDEA based IDE called Android Studio, a dedicated IDE for Android development. It definitely sounds like an interesting project and I recommend to check it out. But on the other hand, I wonder how many developers used to Eclipse will eventually switch to this new IDE? You know, a habit is a shirt made of iron.
Nevertheless, back to what I originally wanted to share with you. You've probably heard of DevAssistant by now. In short, it's a tool which aims to help developers with setting up their development environment. And, as you've probably guessed, we can use this tool to automate the tedious process described above. So let's try it out.

First you need to enable additional Copr repository and install an RPM with Android assistant. You will also need to have package dnf-plugins-core installed in order to effectively work with Copr repositories.

# dnf install dnf-plugins-core
# dnf copr enable msrb/devassistant-android-eclipse
# dnf install devassistant-android-eclipse-assistant

Note the steps above will not be needed in a future, because DevAssistant will have its own repository for assistants (DAPI = DevAssistant Package Index).

Now we are ready to run DevAssistant itself:

$ da task android-eclipse --accept-sdk-license

Of course you can do this from GUI as well (just run "da-gui"), but I think that copy-pasting this one line is simpler and faster. DevAssistant will download and set everything up for you. This may take awhile, so it is an ideal coffee time.

When DevAssistant is done, you can open your Eclipse and start developing Android applications.

Tuesday, April 8, 2014

Jenkins plugin for building RPMs in Copr

Imagine situation that you are continuously building your project in Jenkins, all tests are passing and you think you just fixed some annoying bug. Now it would be great to get some feedback on your fix from the guy who reported the bug or from someone else. You could point the guy to the repo, ask him to rebuild your project and test it. But it could be too much work for him. Maybe he's not a programmer or doesn't have all the necessary development/build tools installed. Even if he is a technical person, a lot of things could go wrong during the process.
I have written simple Jenkins plugin which can build RPM package for every successful Jenkins build. The name of the plugin is "copr-plugin" and as the name suggests, it delegates all the hard work to Copr. Copr handles actual building and puts the resulting RPMs into user-defined repos. It means that people can test what's in your master (or any other) branch by simply installing RPM package. Or you can, for example, enable your Copr repo in VM and have latest development version of your project installed just few minutes after you pushed your changes to the SCM.

Let's take a look on how to set all this up. First of all, you will need FAS account in order to be able to use Copr. Next you should make sure that the project you're trying to build in Copr meets some basic criteria. And that's it, no more constraints. We are now finally getting to the Jenkins plugin itself.

The plugin is not part of the default installation, so you'll need to install it first. Luckily, it is available through official Jenkins channels. Go to "Manage Jenkins->Manage Plugins->Available" and search for "copr plugin". Select the checkbox and click "Install without restart".


Now it is possible to activate the plugin from "Add post-build action" drop-down menu in your project's configuration.

Almost there, one last missing bit is configuration. You need to specify where Copr is running (API URL), your FAS username, name of your Copr repository (coprname), API login and API token. These last two are special credentials generated by Copr, you can get yours here (you must log in first with your FAS username+password).


And here comes the tricky part. You need to feed Copr with URL to SRPM. Copr currently doesn't support uploading SRPMs. However, you can write simple shell script which will create SRPM and upload it to some visible place, so Copr will be able to download it. The script can take advantage of some handy environment variables.


You may also want to wait for Copr to finish the build, but keep in mind that such waiting can block other tasks in Jenkins. If this option is enabled, then failed Copr build means also failed Jenkins job.

And that's it. Happy building.