Installing gamebots as a part of Maven build
Following procedure is considered best practice to deploy Gamebots and other extensions to UDK along with your project.
This article was written for PogamutUDK version 3.2.5. It should seamlessly apply to future versions and with further modifications it is applicable to Pogamut for other versions of unreal. This article was written by Martin Černý.
The idea:
- User specifies path to UDK in his/her settings.xml
- You add a profile to you project's pom, that unpacks Gamebots, and/or other UDK packages to UDK home directory and then executs “udk make”
- Whenever the user wants to install/build/rebuild Gamebots, he/she activates the profile as part of the build
Setting UDK home in settings.xml
As a convention the property for UDK installation dir is called udk.home. Since UDK installation dir is different on every system, it is a good idea to set it in your settings.xml. (in NetBeans you usually find your settings.xml under “Project files” folder of any Maven project). Although specifying a property in your settings.xml is not the most straightforward thing, it is not such a hassle - you only need to declare a custom profile. Example follows:
<?xml version="1.0" encoding="UTF-8" ?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <profiles> <profile> <id>inject-udk-home</id> <properties> <udk.home>D:/Games/UDK-2011-05</udk.home> </properties> </profile> </profiles> <activeProfiles> <activeProfile>inject-udk-home</activeProfile> </activeProfiles> </settings>
Unpacking and compiling GameBots
The default GameBots package is distributed as a zip artifact in our repository. The easiest way to unpack it is to use maven-dependency-plugin. Next you run the compile command with maven-exec-plugin. Note that UDK spawns a separate process for the compilation and the executable we run terminates immediately
- Your build will not fail if build of the gamebots fail
- Your build will likely finish before the scripts are actually compiled, so it is not a good idea to run a bot in the same build
Since UDK supports only Windows, build will fail on any other platform than Windows.
Here is an example of how such a profile looks in your pom.xml
<profiles> <profile> <!-- Custom profile, inactive by default, that installs and builds GameBots--> <id>installGameBots</id> <build> <plugins> <!-- Unpacking the gamebots artifact --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack-gamebots</id> <phase>generate-resources</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>cz.cuni.amis.pogamut</groupId> <artifactId>gamebots-udk</artifactId> <type>zip</type> <outputDirectory>${udk.home}</outputDirectory> <overWrite>true</overWrite> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> <!-- Executing maven compilation --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <id>build-udk</id> <phase>compile</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${udk.home}/Binaries/UDKLift.exe</executable> <commandlineArgs>make</commandlineArgs> </configuration> </execution> </executions> </plugin> </plugins> </build> <!-- Dependency on desired gamebots-udk version --> <dependencies> <dependency> <groupId>cz.cuni.amis.pogamut</groupId> <artifactId>gamebots-udk</artifactId> <version>3.2.5-SNAPSHOT</version> <type>zip</type> </dependency> </dependencies> </profile> </profiles>
Unpacking additional gamebots packages
You might want to add some extensions to the gamebots package or UDK in general, that are not part of the gamebots core (something project-specific). In such a case, you simply add a dependency on the desired UDK extension package to the same profile and add a new artifactItem in the configuration of maven-dependency plugin.
For more information on design and creation of UDK extension packages see UDK extension packages