Chapter 3. Pogamut and Maven

Table of Contents

Getting started
Pogamut without Maven

Getting started

Maven is a build system for Java, besides compiling your code it server the whole lifecycle of your project from the creation to the deployement. This chapter will guide you through minimal setup that is needed to use Maven with Pogamut projects.

  1. Install Maven 3.0.2 or newer - download Maven and carefully follow the installation instructions.

  2. Read Maven documentation to get familiar with the whole system.

  3. Now try to build your first Pogamut bot from a Maven archetype. Issue this command in a shell (in Windows environment remove \ at the end of each line)

    mvn archetype:generate -DgroupId=your.proj.gid -DartifactId=your-proj-aid -DarchetypeGroupId=cz.cuni.amis.pogamut.ut2004.examples -DarchetypeArtifactId=00-empty-bot-archetype -DarchetypeVersion=3.2.0-SNAPSHOT -DarchetypeRepository=http://diana.ms.mff.cuni.cz:8081/artifactory/repo

    You should get this output if everything worked fine.

    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'archetype'.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Default Project
    [INFO]    task-segment: [archetype:generate] (aggregator-style)
    [INFO] ------------------------------------------------------------------------
    [INFO] Preparing archetype:generate
    [INFO] No goals needed for project - skipping
    [INFO] [archetype:generate]
    [INFO] Generating project in Interactive mode
    [INFO] Archetype defined by properties
    [INFO] snapshot cz.cuni.amis.pogamut.ut2004.examples:00-empty-bot-archetype:3.2.0-SNAPSHOT: checking for updates from 00-empty-bot-archetype-repo
    [INFO] snapshot cz.cuni.amis.pogamut.ut2004.examples:00-empty-bot-archetype:3.2.0-SNAPSHOT: checking for updates from amis-repository
    [INFO] Using property: groupId = your.proj.gid
    [INFO] Using property: artifactId = your-proj-aid
    Define value for property 'version': 1.0-SNAPSHOT:
    [INFO] Using property: package = your.proj.gid
    Confirm properties configuration:
    groupId: your.proj.gid
    artifactId: your-proj-aid
    version: 1.0-SNAPSHOT
    package: your.proj.gid
    Y:
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 7 seconds
    [INFO] Finished at: Wed Feb 23 12:06:26 CET 2011
    [INFO] Final Memory: 20M/340M
    [INFO] ------------------------------------------------------------------------
    
  4. [OPTIONAL] Update $USER_HOME/.m2/settings.xml so that it includes reference to the Pogamut repository storing jar files of all necessary libraries. In most cases you don't have to make this step. If you create projects from archetypes the path to AMIS repository will be already included in the created project template. Your settings.xml should look like this:

    <?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>defaultProfile</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
                <repositories>
                    <repository>
                        <id>amis-repository</id>
                        <url>http://diana.ms.mff.cuni.cz:8081/artifactory/repo</url>
                        <snapshots>
                            <enabled>true</enabled>
                            <updatePolicy>always</updatePolicy>
                            <checksumPolicy>fail</checksumPolicy>
                        </snapshots>
                        <releases>
                            <enabled>true</enabled>
                            <checksumPolicy>fail</checksumPolicy>
                        </releases>
                    </repository>
                    <properties>
                        <downloadSources>true</downloadSources>
                        <downloadJavadocs>true</downloadJavadocs>
                    </properties>
                </repositories>
            </profile>
        </profiles>
    </settings>