48

GitをAntと統合するための最良の方法を探しています。Gitで広く使用されているAntタスクはありますか?誰かがAntを介してGitを使用した経験がありますか(たとえば、専用タスク、exec呼び出しなど)?

4

7 に答える 7

23

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

于 2010-07-26T14:43:12.370 に答える
19

Git 用の一連の Ant タスクがあったようには見えません。

このブログでは、Git を操作するためのいくつかの基本的なタスクについて説明します。

于 2009-05-08T17:58:11.030 に答える
6

JGit-Ant を見てください。残念ながら、jgit-antタスク プロジェクトには、すべての主要な git アクションが含まれているわけではありません。追加情報については、こちらを参照してください。

Java 開発者向け:この例のように、jgitを使用して git-ant-commands を自分で簡単に作成できます。

于 2013-03-28T11:21:00.927 に答える
5

gitのAntタスクで追加の非公式な作業が行われたようです。

私はこれらの経験はありませんが、tlrobinsonよりも肉付きが良いように見えます。

于 2010-06-22T01:25:54.533 に答える
0

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

于 2016-10-04T08:10:43.420 に答える
0

Time ago I have unsuccessfully looked for ready in use ways to integrate Git and Ant. I needed possibility to create a build with the name of the Git branch. Finally I came to the following solution:

The excerpt from the real build.xml file:

<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>

The whole content of the file ./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

Invocation is similar to:

ant TARGET options -Dusing.git=

When ${using.git} is declared, Ant calls the task -check-git-branch-name to gather the name of a branch (or a commit's number if Git is in detached mode) and generates the build with the appended name of the Git branch (or commit's hnumber), for example build/TARGET-${git-branch-name}.

于 2016-10-16T21:20:54.840 に答える