środa, 29 grudnia 2010

Java Code Review

Postanowilem utrwalic swoje ostatnie doswiadczenia w poszukiwaniu jakiegos prostego i funkcjonalnego narzedzia do tzw 'code review', czyli w tlumaczeniu na polski - 'oceny kodu' ?
Znalazlem jedno dobrze wygladajace narzedzie, niestety płatne: http://smartbear.com/docs/viewlets/CodeCollabDemo/CodeCollabDemo.html

Postanowiłem więc poszukać czegoś darmowego i znalazlem Java Code Reviewer (JCR). Postanowilem go zainstalowac i spróbowac jak działa.
Niestety na Windowsie po wielu trudach odpuściłem i przerzuciłem sie na Ubuntu 10.10 gdzie instalacja poszła szybko i bezboleśnie.
Potem już po wszystkim znalazłem strone: http://ostatic.com/blog/open-source-code-review-tools i zainteresowałem sie projektem Rietveld, ale o tym może w niedalekiej przyszłości będę jeszcze pisać. Tutaj chciałem przedstawić instalacje JCR.

Download


Zaczynamy od ściągnięcia JCR ze strony http://sourceforge.net/projects/jcodereview/files/
Następnie rozpakowujemy archiwum. U siebie rozpakowalem w folderze
/home/user/dev/jcr-0.7.2.1

Instalacja


Przy instalacji postepujemy zgodnie z instrukcja na stronie z niewielkimi zmianami.


  • Python

  • Sprawdzamy wersje Pythona. Najlatwiej wejsc do konsoli Pythona a wersja zostanie wyswietlona sama:

    user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ python
    Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
    [GCC 4.4.5] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>quit()


    JCR wymaga wersji 2.5+ (rekomendowana) zatem wszystko jest narazie OK.

    Nastenie dociagamy pozostale wymagane moduly.
  • Pysqlite

  • user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo apt-get install python-pysqlite2
    [sudo] password for user:
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Suggested packages:
    python-pysqlite2-doc python-pysqlite2-dbg
    The following NEW packages will be installed:
    python-pysqlite2
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 33.5kB of archives.
    After this operation, 168kB of additional disk space will be used.
    Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick/universe python-pysqlite2 i386 2.6.0-1 [33.5kB]
    Fetched 33.5kB in 0s (89.0kB/s)
    Selecting previously deselected package python-pysqlite2.
    (Reading database ... 143492 files and directories currently installed.)
    Unpacking python-pysqlite2 (from .../python-pysqlite2_2.6.0-1_i386.deb) ...
    Setting up python-pysqlite2 (2.6.0-1) ...
    Processing triggers for python-central ...


  • Pysvn


  • user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo apt-get install python-svn
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following extra packages will be installed:
    libapr1 libaprutil1 libsvn1
    Suggested packages:
    python-svn-dbg
    The following NEW packages will be installed:
    libapr1 libaprutil1 libsvn1 python-svn
    0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
    Need to get 1,389kB of archives.
    After this operation, 3,920kB of additional disk space will be used.
    Do you want to continue [Y/n]? y
    Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick/main libapr1 i386 1.4.2-3ubuntu1 [83.0kB]
    Get:2 http://us.archive.ubuntu.com/ubuntu/ maverick-updates/main libaprutil1 i386 1.3.9+dfsg-3ubuntu0.10.10.1 [84.3kB]
    Get:3 http://us.archive.ubuntu.com/ubuntu/ maverick/main libsvn1 i386 1.6.12dfsg-1ubuntu1 [839kB]
    Get:4 http://us.archive.ubuntu.com/ubuntu/ maverick/main python-svn i386 1.7.2-3ubuntu1 [383kB]
    Fetched 1,389kB in 1s (1,074kB/s)
    Selecting previously deselected package libapr1.
    (Reading database ... 143504 files and directories currently installed.)
    Unpacking libapr1 (from .../libapr1_1.4.2-3ubuntu1_i386.deb) ...
    Selecting previously deselected package libaprutil1.
    Unpacking libaprutil1 (from .../libaprutil1_1.3.9+dfsg-3ubuntu0.10.10.1_i386.deb) ...
    Selecting previously deselected package libsvn1.
    Unpacking libsvn1 (from .../libsvn1_1.6.12dfsg-1ubuntu1_i386.deb) ...
    Selecting previously deselected package python-svn.
    Unpacking python-svn (from .../python-svn_1.7.2-3ubuntu1_i386.deb) ...
    Setting up libapr1 (1.4.2-3ubuntu1) ...
    Setting up libaprutil1 (1.3.9+dfsg-3ubuntu0.10.10.1) ...
    Setting up libsvn1 (1.6.12dfsg-1ubuntu1) ...
    Setting up python-svn (1.7.2-3ubuntu1) ...
    Processing triggers for libc-bin ...
    ldconfig deferred processing now taking place


  • easy_install


  • user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ wget http://peak.telecommunity.com/dist/ez_setup.py--2010-12-29 13:01:31-- http://peak.telecommunity.com/dist/ez_setup.py
    Resolving peak.telecommunity.com... 209.190.5.234
    Connecting to peak.telecommunity.com|209.190.5.234|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 10285 (10K) [text/plain]
    Saving to: `ez_setup.py'


    100%[===================================================>] 10,285 38.0K/s in 0.3s


    2010-12-29 13:01:32 (38.0 KB/s) - `ez_setup.py' saved [10285/10285]


    Uruchamiamy skrypt

    user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo python ez_setup.py
    Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
    Processing setuptools-0.6c11-py2.6.egg
    Copying setuptools-0.6c11-py2.6.egg to /usr/local/lib/python2.6/dist-packages
    Adding setuptools 0.6c11 to easy-install.pth file
    Installing easy_install script to /usr/local/bin
    Installing easy_install-2.6 script to /usr/local/bin


    Installed /usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg
    Processing dependencies for setuptools==0.6c11
    Finished processing dependencies for setuptools==0.6c11



W reszcie instalujemy samo JCR

user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo easy_install -f . jcr


Potrwa to chwile, koncowe logi powinny wygladac podobnie do tych

Running python-openid-2.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-bwfet4/python-openid-2.2.5/egg-dist-tmp-xHPrM6
warning: no files found matching 'CHANGELOG'
warning: no files found matching '*.css' under directory 'doc'
warning: no files found matching '*.html' under directory 'doc'
zip_safe flag not set; analyzing archive contents...
Adding python-openid 2.2.5 to easy-install.pth file


Installed /usr/local/lib/python2.6/dist-packages/python_openid-2.2.5-py2.6.egg
Finished processing dependencies for jcr


Instalujemy pysqlite

user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo easy_install pysqlite
Searching for pysqlite
Best match: pysqlite 2.6.0
Adding pysqlite 2.6.0 to easy-install.pth file

Using /usr/lib/python2.6/dist-packages
Processing dependencies for pysqlite
Finished processing dependencies for pysqlite



Generujemy plik konfiguracyjny dla JCR

user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo paster make-config jcr jcr.ini
Distribution already installed:
jcr 0.7.2.1 from /usr/local/lib/python2.6/dist-packages/jcr-0.7.2.1.egg
Creating jcr.ini
Now you should edit the config files
jcr.ini



Uruchamiamy setup

user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo paster setup-app jcr.ini

i dostajemy blad o brakujacym module

ImportError: No module named profile; please install the python-profiler package

Zatem doinstalowujemy modul

user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo apt-get install python-profiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
python-doc
The following NEW packages will be installed:
python-profiler
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 41.2kB of archives.
After this operation, 233kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick/multiverse python-profiler all 2.6.6-0ubuntu1 [41.2kB]
Fetched 41.2kB in 0s (96.5kB/s)
Selecting previously deselected package python-profiler.
(Reading database ... 143579 files and directories currently installed.)
Unpacking python-profiler (from .../python-profiler_2.6.6-0ubuntu1_all.deb) ...
Setting up python-profiler (2.6.6-0ubuntu1) ...


i ponownie uruchamiamy setup

user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo paster setup-app jcr.ini

Na zapytania odpowiadamy twierdzaco:

----------------------------------------------------------------------
Checking and initialising JCR
----------------------------------------------------------------------
1. Confirm values read from the config file
Database URL: sqlite:////home/user/dev/jcr-0.7.2.1/jcr-sqlite.db
Base directory: /home/user/dev/jcr-0.7.2.1/var

Are these correct? [Y or N]: Y

----------------------------------------------------------------------
2. Checking database

- Attempting to connect...
... Connected OK

- Checking schema...

Warning: your database schema has not been created!

Would you like to have the schema created for you? [Y or N]: Y
Creating schema ...
... schema created OK

- Checking for superuser...

Warning: your database contains no superuser
Would you like a superuser created for you? [Y or N]: Y
... superuser created OK

Username: admin
Password: password0


----------------------------------------------------------------------
3. Checking directories

- Checking for directory existence...

Warning: the required directories do not exist under /home/user/dev/jcr-0.7.2.1/var
Would you like to have the directories created for you? [Y or N]: Y
... directories created OK
- Checking that directories are writeable...
... directory access OK

----------------------------------------------------------------------
4. Checking Version Control System external dependencies

VCS: Subversion .... OK
VCS: Local .... OK

----------------------------------------------------------------------
5. Checking for review projects

Your database is empty.
Would you like to have a sample review project created, so that you can play around with JCR? [Y or N]: Y
Inserting test project in database ...
... project inserted OK
Copying project files ...
... project files copied OK

----------------------------------------------------------------------
Congratulations - JCR should be ready to use!
Start JCR with the following command line:

paster serve /home/user/dev/jcr-0.7.2.1/jcr.ini


Uruchamiamy serwer

user@ubuntu1010desktop:~/dev/jcr-0.7.2.1$ sudo paster serve jcr.ini
/usr/local/lib/python2.6/dist-packages/jcr-0.7.2.1.egg/jcr/model/systemuser.py:10: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5, orm, project, fileaction, projectreviewer
Starting server in PID 2816.
serving on 0.0.0.0:5000 view at http://127.0.0.1:5000


Nastepnie w przegladarce odpalamy strone

http://127.0.0.1:5000

Logujemy sie jako admin/password0
Takie jest domyslne haslo i login administratora systemu.
Terac juz mozemy pobawic sie testowym projektem, ktory jest tworzony wraz z instalacja.

1 komentarz:

  1. fajny blog :) zapraszam do mnie te� :) http://elektroinstalatorstwo.augustow.pl/

    OdpowiedzUsuń