Monday, May 13, 2013

Removing Unused Dependencies in IDEA Projects

In this post I write about Jonnyzzz Dependencies plugin that helps one to remove unused dependencies between modules and libraries

Problem Statement

Let's say you have a project of 20+ modules. This project is quite old, there are a number of dependencies between modules and libraries. There were many people who pushed=commited changes to it. So the question is how to figure out and remove unused libraries and module dependencies. Jonnyzzz Dependencies plugin is designed to help you to solve the issue easily

In the IDEA you'll find an action under main menu: Tools | Remove Unused Module Dependencies. Here you may analyze dependencies for selected number of modules or for entire project.

Results of search are shown in the dialog. Next you may remove all dependencies in one click!

Plugin Implementation Details

First of all, it was tricky to use ReadAction/WriteAction in IDEA API. Long running ReadAction in plugin code could easily lead to deadlock. When IDEA instance loses focus it attempts to get WriteLock to persist project, so this would be a deadlock with UI thread. The right thing is to to take ReadLock only for show time slots (but many times)

Implementation of the plugin is straightforward. For selected modules I take files, there I take all references and resolve them. Resolved elements allows me to find actual set of dependencies. Next I compute difference between project defined dependencies and actual computed dependencies. Thanks to a huge number of IDEA API classes I implemented this search to run in all available processor cores

There are integration tests in the plugin sources that helps me to check major plugin use-cases. That was amazing to have integration tests framework!

It was nice experience to write a real working plugin for Intellij IDEA platform!

This plugin analyzed only COMPILE and TEST dependencies. PROVIDED and RUNTIME dependencies are not analyzed.

Plugin Sources

You may download a build of the plugin repository. Plugin is provided under Apache 2.0 license. Sources are on GitHub

Tuesday, April 30, 2013

Adding Grunt Support to TeamCity.Node

In this post I cover recent updates that I done to TeamCity.Node plugin. I blogged about the plugin here. Grunt support is added to the plugin!

Grunt Runner implementation

By default, this runner will only run on a build agent that has Node.js detected. This is quite handy since Node.js is required to run Grunt

The Grunt runner checks if you have grunt and grunt-cli dependency in your project's NPM packages repository. (If you don't, you may add Node.js NPM runner to download dependencies for you!). Next it computes an executable path to run Grunt

Runner settings UI looks in the following way:

This plugin also provides support for Node.js, Node.js Package Manager (NPM) and Phantom.js

Downloading TeamCity.Node

This plugin is provided under Apache 2.0 license. Sources (in Kotlin) are found on GitHub. You may download compiled build from TeamCity

Saturday, April 27, 2013

GitHub Change Status on Branches

Recently I wrote about GitHub commit status support in TeamCity

Today I was shown (thanks Vlad!) a post that GitHub started to show commit status on branches view! For more information you may see original GitHub blog post

The fun thing is that TeamCity.GitHub plugin reports that status for every branch. So to have statuses for branches you do not need even to update the plugin!

Take a look what I see on my GitHub now!

Downloading and Installing TeamCity.GitHub plugin

Sources are on GitHub: https://github.com/jonnyzzz/TeamCity.GitHub

You can download a build from our TeamCity: here.
TeamCity.GitHub plugin is compiled with TeamCity 7.1. Is supports TeamCity 8.0 EAP and may work with older versions.