Use log4j-1.2.14 instead of 1.2.15 in Maven Project

May 3rd, 2008

log4j-1.2.15 has a dependency on sun-jms-1.1, which is broken in Maven repository.

Share

Get Maven project from svn to Eclipse

May 3rd, 2008

When you put a maven project under source control like SVN, you don’t have to check in the IDE’s project file. What you will do is check in the pom.xml and the source folder.  That is enough for you to rebuild the project.

If you want to continue work on this project on your favorite IDE (like Eclipse) again, you can simply choose “File-import” and from the dialog box, select “Other – Check out Maven Project from scm” and the locate you source repository in the following wizard, and you are good to go. The Maven plugin will generate the project file for you according to pom file settings.

Share

Create an Eclipse Project by Maven

April 28th, 2008

You will install this 2 plugin: eclipse plugin for maven and m2eclipse( Maven 2 Eclipse plugin ).

First, you create a Maven project layout:

mvn archetype:create -DgroupId=com.langcode \
                     -DartifactId=Test

This will create a folder named Test ( artifactId, which is your release jar file base name).

After that, we will create the Eclipse project file:

cd Test

mvn eclipse:eclipse

Now, we can start the Eclipse and import the project we created. And do the following steps:

  1. Right click on the project and enable Maven Package management.
  2. Update Maven dependency.
  3. Update Maven Source folder.

Now, you have an Eclipse development set up. You will want to add some common maven phase into Run menu using the “Run As” Dialog. Or, you can do it manually in CLI.

Some common tasks are:

Clean up:

mvn clean

Build Jar:

mvn package

Copy all dependencies into target folder:

mvn dependency:copy-dependencies

Run Test:

mvn test
Share

Maven

April 28th, 2008

These few days, I have special interests on maven. A java ( well, I am not sure if it is Java only) building tool.

The reason I am looking for a building tool is we are currently changing our development tool chain from NetBeans to Eclipse ( Some Windows nuts insist on JBuilder, which is based on Eclipse as well ). The problem is we have to do a lot to convert the projects to eclipse ones and have them built under eclipse. So, we want to find an IDE neutral build environment.

what is Maven?

Maven, a Yiddish word meaning accumulator of knowledge , was originally started as an attempt to simplify the build processes in the Jakarta Turbine project. There were several projects each with their own Ant build files that were all slightly different and JARs were checked into CVS. We wanted a standard way to build the projects, a clear definition of what the project consisted of, an easy way to publish project information and a way to share JARs across several projects.

The result is a tool that can now be used for building and managing any Java-based project. We hope that we have created something that will make the day-to-day work of Java developers easier and generally help with the comprehension of any Java-based project.

Maven’s Objectives

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with:

  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features
Share

How to get the absolute path to the folder of current program

December 24th, 2007
PROG_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
Share

How to determine Current Fedora version

December 23rd, 2007

use rpm command:

rpm -q --queryformat '%{VERSION}' fedora-release

or check file:

cat /etc/fedora-release | sed 's/^.*release.([0-9]+).*$/1/'
Share

Setup rsync server

December 20th, 2007

For example, we want to set up an rsync server to duplicate the subversion server data to other computers.

First, of cause we have to have rsync installed. For fedora, this should be included in default installation.

Then we will create the config folder and config in Fedora’s style:

cd /etc
mkdir rsyncd
cd rsyncd
touch rsyncd.conf
touch rsyncd.motd
touch rsyncd.secrets
chmod 600 rsyncd.secrets

Then will edit rsyncd.conf file:

pid file=/var/run/rsyncd.pid
port=873
address=192.168.2.111
uid=root
gid=root
use chroot=yes
read only=yes

# limit access to LANS
hosts allow=192.168.2.0/255.255.255.0
host deny=*

max connections=5
motd file=/etc/rsyncd/rsyncd.motd

log format=%t%a%m%f%b
syslog facility=local3
timeout=300

[svn]
path=/var/www/svn
list=yes
ignore errors
auth users=svnsyncer
secrets file=/etc/rsyncd/rsyncd.secrets
comment=SVN Repository

We will add the welcome message to /etc/rsyncd/rsyncd.motd

Welcome the SVN rsync service

Add user/password to /etc/rsyncd/rsyncd.secrets

svnsyncer:123456

And then, we will create our init start up script named /etc/init.d/rsyncd

#!/bin/sh
#
# Startup script for rsyncd daemon
#
# chkconfig: 35 90 10
# description: Server data for sync to other server
# processname rsync

# Source function library
. /etc/rc.d/init.d/functions

prog=rsync
conf=/etc/rsyncd/rsyncd.conf

case "$1" in
    start)
        echo -n "Starting rsync daemon: "
        daemon /usr/bin/$prog --daemon --config=$conf
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/$prog
        ;;
    stop)
        echo -n "Shutting down $prog: "
        killproc -d 60 $prog
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog
        ;;
    status)
        status $prog
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit 0

We will register and this service by

/sbin/chkconfig --add rsyncd
/sbin/service rsyncd start
Share

SSH no password login

December 19th, 2007

first, on your local machine, generate the key pair:

ssh-keygen -t dsa

Copy public key file .ssh/id_dsa.pub to server you are going to login.

Append the key to .ssh/authorized_keys by

cat id_dsa.pub >> .ssh/authorized_keys
Share

Install sun JDK on Fedora 8

December 7th, 2007

Download JDK from Sun’s website, and install it. The default install path should under /usr/java.

We create a new alternative entry:

/usr/sbin/alternatives --install
    /usr/bin/java java
    /usr/java/latest/jre/bin/java 2

and then we config the java alternative settings, select the sun version:

/usr/sbin/alternatives --config java

And we are good to go.

Share

How to set up fcitx under FC7 with en_US.utf-8 locale

October 12th, 2007

First, you can download the source tarball and use the regular configure, make and make install procedure to install it.

Then create a new input method entry: /etc/X11/xinit/xinput.d/fcitx.conf, with the content:

XIM=fcitx

XIM_PROGRAM=fcitx

GTK_IM_MODULE=fcitx

QT_IM_MODULE=fcitx

Create and set up alternatives using fcitx

alternatives --install /etc/X11/xinit/xinputrc
 xinputrc /etc/X11/xinit/xinput.d/fcitx.conf 100

alternatives --config xinputrc

Now, fcitx should be good to use under zh_CN locale. If you want to use under en_US locale, do the following as well.

Edit /etc/X11/xinit/xinitrc.d/xinput.sh, add “en” to the “_language_list” string.

Edit /etc/gtk-2.0/x86_64-redhat-linux-gnu/gtk-immodules, add “en” to “xim” section.

Share