+1 (972) 883-2091
ECSS 4.220, 800 W Campbell Rd, Richardson, TX 75083–0688, US

Tunning the traffic project configuration

In this tutorial, we describe the process of updating the maven project’s configurations to manage the project’s dependencies, build, and reporting settings.

  1. To better understand the project’s structure and how its inner packages are decomposed, we change the project and package presentations to a hierarchical view. We can do this by:
    1. As shown in the figure below, press the inverted triangle button located at the top right corner of your project explorer, choose “Projects Presentation” and select “Hierarchical”.
    2. In the same way, press the inverted triangle button located at the top right corner of your project explorer again, choose “Package Presentation” and select “Hierarchical”.
  2. Open the project object model (POM) for the “traffic” project. To do so, double click on the file pom.xml under the “traffic” project. The Maven POM Editor should appear.

    1. In the opened window, click on the tab “pom.xml” as show in the figure below.

      The content of the project object model (POM) should be displayed in XML format as follows:

      <?xml version="1.0" encoding="UTF-8"?>
                  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                     <modelVersion>4.0.0</modelVersion>
                     <groupId>edu.utdallas.mavs.traffic</groupId>
                     <artifactId>traffic</artifactId>
                     <version>1.0.0-SNAPSHOT</version>
                     <packaging>pom</packaging>
                     <name>Traffic Simulation System</name>
                     <description>This is a tutorial on how to create a simple Traffic Simulation System.</description>
                     <modules>
                        <module>traffic-gui</module>
                        <module>traffic-simulation</module>
                        <module>traffic-visualization</module>
                     </modules>
                  </project>
      
      
      
  3. Add information about the project developers to the “pom.xml” file as follows:
      
                <developers>
                   <developer>
                      <id>Al-Zinati</id>
                      <name>Mohammad</name>
                      <email>mha091020@utdallas.edu</email>
                      <url />
                      <organization />
                      <organizationUrl />
                      <roles>
                         <role>Architect</role>
                         <role>Developer</role>
                      </roles>
                      <timezone />
                      <properties />
                   </developer>
                </developers>
    
  4. Add the version number of all external libraries that will be used to develop the traffic simulator to the “pom.xml” file as follows:
     
    <properties>
                   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                   <myjdkversion>1.7</myjdkversion>
                   <jmonkey.version>3.0.0-09.24.2012-SNAPSHOT</jmonkey.version>
                   <nifty.version>1.3.1</nifty.version>
                   <slf4j.version>1.7.2</slf4j.version>
                   <log4j.version>1.2.17</log4j.version>
                   <junit.version>4.10</junit.version>
                   <guice.version>3.0</guice.version>
                   <activeMQ.version>5.7.0</activeMQ.version>
                   <divas.version>4.0.19-SNAPSHOT</divas.version>
                   <jgrapht.version>1.0.0</jgrapht.version>
                </properties>
    

    You can always add more libraries when needed.

  5. Add information about all external libraries (dependencies) that will be used globally in this project. You can get the information about each of these dependencies using Maven Repository website. For instance, we use the libraries “log4j”, “slf4j”, and “junit” across all the “traffic” project modules. The following lines should be added to the “pom.xml”:
                
    <dependencies>
                   <!-- Logging -->
                   <dependency>
                      <groupId>org.slf4j</groupId>
                      <artifactId>slf4j-api</artifactId>
                      <version>${slf4j.version}</version>
                   </dependency>
                   <dependency>
                      <groupId>org.slf4j</groupId>
                      <artifactId>slf4j-log4j12</artifactId>
                      <version>${slf4j.version}</version>
                   </dependency>
                   <dependency>
                      <groupId>log4j</groupId>
                      <artifactId>log4j</artifactId>
                      <version>${log4j.version}</version>
                   </dependency>
                   <dependency>
                      <groupId>junit</groupId>
                      <artifactId>junit</artifactId>
                      <version>${junit.version}</version>
                      <scope>test</scope>
                   </dependency>
                   <dependency>
                      <groupId>org.jgrapht</groupId>
                      <artifactId>jgrapht-core</artifactId>
                      <version>${jgrapht.version}</version>
                   </dependency>
                </dependencies>
    
  6. Copy/paste the following code into the “pom.xml” file to define how your project will be built by maven:
               
    <build>
                   <pluginManagement>
                      <plugins>
                         <plugin>
                            <artifactId>maven-compiler-plugin</artifactId>
                            <version>2.5.1</version>
                         </plugin>
                         <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-javadoc-plugin</artifactId>
                            <version>2.8.1</version>
                         </plugin>
                         <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>2.12.3</version>
                         </plugin>
                         <plugin>
                            <artifactId>maven-assembly-plugin</artifactId>
                            <version>2.3</version>
                         </plugin>
                         <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-checkstyle-plugin</artifactId>
                            <version>2.9.1</version>
                         </plugin>
                         <plugin>
                            <artifactId>maven-antrun-plugin</artifactId>
                            <version>1.7</version>
                         </plugin>
                         <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-dependency-plugin</artifactId>
                            <version>2.5.1</version>
                         </plugin>
                         <plugin>
                            <groupId>org.eclipse.m2e</groupId>
                            <artifactId>lifecycle-mapping</artifactId>
                            <version>1.0.0</version>
                            <configuration>
                               <lifecycleMappingMetadata>
                                  <pluginExecutions>
                                     <pluginExecution>
                                        <pluginExecutionFilter>
                                           <groupId>org.apache.maven.plugins</groupId>
                                           <artifactId>maven-dependency-plugin</artifactId>
                                           <versionRange>2.5.1</versionRange>
                                           <goals>
                                              <goal>unpack</goal>
                                              <goal>copy-dependencies</goal>
                                           </goals>
                                        </pluginExecutionFilter>
                                        <action>
                                           <ignore />
                                        </action>
                                     </pluginExecution>
                                  </pluginExecutions>
                               </lifecycleMappingMetadata>
                            </configuration>
                         </plugin>
                      </plugins>
                   </pluginManagement>
                   <plugins>
                      <plugin>
                         <artifactId>maven-compiler-plugin</artifactId>
                         <configuration>
                            <source>1.7</source>
                            <target>1.7</target>
                         </configuration>
                      </plugin>
                      <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-surefire-plugin</artifactId>
                      </plugin>
                      <plugin>
                         <artifactId>maven-javadoc-plugin</artifactId>
                         <executions>
                            <execution>
                               <id>attach-javadocs</id>
                               <phase>deploy</phase>
                               <goals>
                                  <goal>jar</goal>
                               </goals>
                            </execution>
                         </executions>
                      </plugin>
                      <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-checkstyle-plugin</artifactId>
                         <configuration>
                            <enableRulesSummary>false</enableRulesSummary>
                            <configLocation>checkstyle.xml</configLocation>
                         </configuration>
                      </plugin>
                   </plugins>
                </build>
    
    
                      <repositories>
                      <repository>
                         <id>utdrepository</id>
                         <url>http://www.utdmavs.org/divas4/m2/repository</url>
                      </repository>
                      </repositories>
    
  7. Finally, refresh the maven project. Right click the “traffic” project in the project explorer > Maven > Update Project Make sure “Force Update of Snapshots/Releases” is checked and press “OK”.