Thursday, June 15, 2006

Maven Nautilus Scripts

I've been using Maven2 a lot recently, and I wrote some simple Nautilus scripts to make my life a bit easier. I never had any problem running mvn commands myself, but thought it would help Maven beginners get started quickly without having to read all the documents first. My scripts should work in any GNOME 2.x (I'm using GNOME 2.14) environment.

Let's see some screen shots first.

Create a Maven Project

You can right click in any folder and create a Maven project right there.

Step 1, enter the groupId of your project.

Step 2, enter the artifactId of your project.

Step 3, choose an Archetype.

Step 4, Your project has been created!

You can now work on your new Maven project!


Install 3rd-party Jars

To install a 3rd party JAR to your local repository, just right-click on the file and select "Install Package"

The script automatically detects all available Java packages in the JAR, you can simply select a package name as the groupId. If you don't like any groupId detected by the script, click "Cancel" and enter whatever groupId you want.

Change the artifactId if it's not what you want.

Enter the version number

and the packing type...

The JAR has been installed to your local repository!


The scripts are pretty simple right now, I'm planning some improvements and new features, here's my TODO:

Version 0.2
- implement command "Deploy Package" that deploys packages to remote
repositories
- implement command "Run..." that prompts a list of builtin goals, the user
can select a goal and run it right away from the current directory

Version 0.3
- GUI for downloading and installing Sun JARs

Version X.X (unscheduled)
- Simple GUI for $HOME/.m2/settings.xml that allows the user to add a mirror,
configure a proxy, etc.
- Auto update nautilus-maven-scripts
- Auto update maven2 (through sudo or gksu if not installed in home dir)

Wednesday, January 25, 2006

Can't get 100% test coverage because of logging statements?

I was looking for a way that I can filter out all the logging statements such as:

if (log.isDebugEnabled())

and found that clover is capable of doing that, but as we're using Maven 2, the maven clover plugin doesn't seem to support it now, believe me, I've reviewed their source code.

Finally I found a solution that does the trick. In your test case, just set the logging level of the class under test to whatever you want, test your class and then set the logging level back! e.g. your class is foo.bar.MyClass


Logger logger = Logger.getLogger("foo.bar");
Level oldLevel = logger.getLevel();
logger.setLevel(Level.OFF);

// test your class here...

logger.setLevel(oldLevel);