2009-05-08 18 views
46

GitとAntを統合する最良の方法を探しています。 GitのAntタスクが広く使われていますか? Antを使ってGitを使う経験がある人はいますか?(例:専用タスク、execコールなど)GitとAntを統合する最良の方法は?

+2

より詳細な質問はhttp://stackoverflow.com/questions/2974106/how-to-lookup-the-latest-git-commit-hash-from-an-ant-build-scriptです。そこの回答もここで役立つかもしれません。 – koppor

答えて

19

Git用のAntタスクのセットがないように見えます。

This blog Gitで作業するための基本的な作業について説明します。

+1

ここにはJitを使ったGit Antタスクがありますhttp://aniszczyk.org/2011/05/12/git-ant-tasks-via-jgit/ –

+0

これは 'git clone'、' git init'と 'git checkout '。 – zb226

+1

ブログは古くなっています。ブログリンク –

21

Antは、実行するコマンドライン(Gitを含む)をコマンドラインに渡すために使用できるexec commandをサポートしています。あなたはいつもそれを取り戻すことができます。

6

Look at JGit-Ant。残念ながら、jgit-antタスクプロジェクトはすべての主要なgitアクションを持っていません。追加情報hereが見つかります。

Java開発者の方には、this examplesのようにjgitを使ってgit-ant-commandsを簡単に書くことができます。

+0

のリンクが壊れています。 – Valentino

0

<script language="javascript">コードでJGitライブラリを組み合わせて使用​​します(私はRhino rubraryを使用しましたが、Groovyなども同様に使用できます)。

0

私はGitとAntを統合するための準備ができていない方法を探しました。私はGitブランチの名前でビルドを作成する可能性が必要でした。

本当build.xmlファイルからの抜粋:最後に、私は以下のソリューションに来た

<target name="-check-git-branch-name" 
    if="using.git" 
    > 
    <exec executable="bash" logError="true" failonerror="true" 
     outputproperty="git-branch-name"> 
     <arg value="./bin/git-branch-name.sh" /> 
    </exec> 
</target> 

ファイル./bin/git-branch-name.sh

#!/bin/bash 

# This script is the part of integration GIT to ANT. Once launched it 
# should return the name of the current branch or the current commit (if 
# GIT is the detached HEAD mode). Further the printed name is appended to 
# the name of the resulting directory. To initialize this feature you need 
# to run ANT with the option "-Dusing.git=". 

exec 2>/dev/null 

git rev-parse --abbrev-ref HEAD | grep -v HEAD || git rev-parse HEAD 

呼び出しの全体の内容は次のようになります

ant TARGET options -Dusing.git= 

${using.git}がde Antは、ブランチの名前(またはGitがデタッチモードの場合はコミットの番号)を収集するために-check-git-branch-nameというタスクを呼び出し、Gitブランチの名前(またはコミットのhnumber)を付けてビルドを生成します。たとえば、build/TARGET-${git-branch-name}です。

関連する問題