ProtocolBuffersのソース生成をmavenのビルドプロセスに組み込む

ProtocolBuffersのバイナリをproject直下のtoolsに展開

/tools/protobuf-2.3.0.tar.gz
/tools/protoc
/tools/protoc-2.3.0-win32.zip
/tools/protoc.exe

圧縮ファイルも置いとくとバージョンが分って親切かも…


定義ファイルをsrc/main/protobuf/におく

pom.xmlのpluginsに下記antrunを追加

<project>
  ....
  <build>
    ......
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>
                <condition property="protoc" value="protoc.exe" else="protoc">
                  <os family="windows" />
                </condition>
                <exec executable="${basedir}/tools/${protoc}">
                  <arg value="--java_out=src/main/java" />
                  <arg value="src/main/protobuf/定義ファイル" />
                </exec>
              </tasks>
              <sourceRoot>src/main/java</sourceRoot>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

あとは

mvn compile

で定義ファイルの設定に従ってソースが生成される

CentOSにおけるパッケージの自動インストールスクリプト

#!/bin/bash

echo "prechecking package..."
LANG=C

REQUIRED_PACKAGES="sysstat sudo libidn \
fetchmail gmp \
compat-libstdc++-296 \
compat-libstdc++-33 libtool-ltdl \
wget patch \
gcc zlib-devel \
bzip2-devel ncurses-devel \
make"

INSTALLING_PACKAGES=`rpm -q $REQUIRED_PACKAGES |grep "is not installed" |cut -d
" " -f 2`

if [ "x$INSTALLING_PACKAGES" != "x" ]; then
        echo "Installing package $INSTALLING_PACKAGES"
        yum -y install $INSTALLING_PACKAGES
fi

echo "checking packages end!!"

ビルドメモ

ビルド用ドキュメント

  • INSTALL-SOURCE

該当箇所の引用(configureは個別設定)

2.9.1. Source Installation Overview

   The basic commands that you must execute to install a MySQL source
   distribution are:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> bin/mysqld_safe --user=mysql &

起動設定

cd support-files
cp mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --add mysql

NERDcommenterのscheme用設定

NERDcommenterコメントアウトを楽におこなうvimのpluginです。

600種類にものぼる膨大なファイルに応じたコメントアウトができるのですが、何故かschemeはサポートされてないようです。

無いなら足すだけですね。早速足しましょう。


pluginのNERD_commenter.vimをエディタで開きます。

function s:SetUpForNewFiletype(filetype, forceReset)
でファイルタイプごとにコメントのデリミタを設定している箇所があります。


そこにscheme用の定義を追加します。

--- NERD_commenter.vim.org      Tue Jan 05 00:29:00 2010
+++ NERD_commenter.vim  Tue Jan 05 00:13:04 2010
@@ -573,6 +573,8 @@
         call s:MapDelimitersWithAlternative('//','', '/*','*/')
     elseif a:filetype ==? "scilab"
         call s:MapDelimiters('//', '')
+    elseif a:filetype ==? "scheme"
+        call s:MapDelimiters(';', '')
     elseif a:filetype ==? "scsh"
         call s:MapDelimiters(';', '')
     elseif a:filetype ==? "sed"

これだけ!!

追記

vimscriptをいじらなくても設定できるそうです。(id:thincaさんありがとうございます。)

~/.vim/after/ftplugin/scheme.vimに以下の一行を足すだけです。

setlocal commentstring=;\ %s

さらに追記

まったく同じやりとりが、既になされてたみたいです(汗)
ちゃんとぐぐれよ自分…。

http://d.hatena.ne.jp/kajisuke/20090807/1249643253