Introduction to geant PreviousNext

Hello World

To find out whether a tool or library is appropriate for my needs I always found it useful to have an easy start which does save my time and thus makes my decision easier. This is why I start with the ubiqituous 'Hello world'. Here is our 'hello_world' build script:

  <?xml version="1.0" ?>
  <project name="hello" default="hello">
    <target name="hello">
      <echo message="Hello world"/>
    </target>
  </project>

		

On the first line you can find the usual XML declaration. The second line contains the project element which is the root element of an eant XML document. Then there is a target element containing one task element, echo in this case. Save the above code in a file called build.eant and invoke in that directory the command geant. The message Hello world will be output.

Typical script that covers compilation

The following script covers 90% of the cases people use geant for. It inherits the Gobo default tasks and only adds project specific info:

<?xml version="1.0"?>

<project name="my_project" inherit="${GOBO}/misc/eiffel.eant" default="help">

	<description>
		system:      "My example"
		author:      "John Doe [john@doe.net]"
		copyright:   "Copyright (c) 2004, John Doe and others"
		license:     "MIT License"
		date:        "$Date$"
		revision:    "$Revision$"
	</description>

	<target name="init_system">
		<set name="system" value="my_program"/>
		<set name="system_dir" value="."/>
	</target>

</project>

    

This script assumes you have a system.ecf in your system_dir.

With this script it is now possible to compile the project for Gobo Eiffel by typing geant compile_ge or to compile it in debug mode for ISE Eiffel by typing geant compile_debug_ise.

You have to be in the project directory when invoking geant. This is due to the specification of a dot as the directory in the set system_dir task. If you have an environment variable that points to the root of your project directory (recommended), the script would look like this:

<project name="my_project" inherit="${GOBO}/misc/eiffel.eant" default="help">

	<target name="init_system">
		<set name="system" value="my_program"/>
		<set name="system_dir" value="${MY_PROJECT}/src/my_program"/>
	</target>

</project>

It is now possible to invoke this build.eant script from any location.

Typical script that covers Gobo Test

The following script covers the typical cases of using the Gobo Test frame work to test your classes. It inherits from test.eant which provides most of the scripting functionality.

<?xml version="1.0"?>

<project name="my_test" inherit="${GOBO}/misc/test.eant" default="help">

	<description>
		system:      "tests for my project"
		author:      "John Doe [john@doe.com]"
		copyright:   "Copyright (c) 2004, John Doe Ltd."
	</description>

	<target name="init_system">
		<set name="system" value="my_test"/>
		<set name="system_dir" value="${MY_PROJECT}/test/feature"/>
	</target>

</project>

As for the compile build.eant, the only two settings that are important are the values of the system and system_dir variables.

With this script it is now possible to test the project for SmartEiffel by typing geant test_se. Test it with VisualEiffel by typing geant test_ve. Test it in debug mode for ISE Eiffel by typing geant test_debug_ise.


Copyright © 2002-2019, Sven Ehrke
mailto:ericb@gobosoft.com
http://www.gobosoft.com
Last Updated: 15 March 2019
HomeTocPreviousNext