Eclipse creates directory .externalToolBuilders
to keep tools settings.
Example of git-version.launch
:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/projX/.externalToolBuilders/git-version.bat}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/projX}"/>
</launchConfiguration>
and git-version.bat
:
@echo off
set VFILE=META-INF/git.properties
git rev-parse --short HEAD >%VFILE%
if ERRORLEVEL 1 (
set hasgit=no
) else (
set hasgit=yes
)
rem Git revision.
if %hasgit% == yes (
set /p rev= <%VFILE%
) else (
set rev=unknown
)
echo git.rev=%rev% >%VFILE%
rem Are sources has local changes?
if %hasgit% == yes (
git diff-index --quiet HEAD
if ERRORLEVEL 1 (
echo git.clean=no >>%VFILE%
) else (
echo git.clean=yes >>%VFILE%
)
)
Build command is registered in .project
:
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value><project>/.externalToolBuilders/git-version.launch</value>
</dictionary>
</arguments>
</buildCommand>