Skip to content

Tutorial: Creating a Module Using Maven

rstauffe edited this page Jun 13, 2013 · 7 revisions

Creating a Module using Maven

If you are unfamiliar with Maven or would like a refresher see our quick Maven guide.

If you do not have Maven installed, please see the Maven installation guide.

  1. In a new terminal, create a new Maven project with the following command, making sure to change the groupId line and the artifactId line. The groupId behaves as the base package name and the artifactId is the single class it will generate. Please keep your groupId unique and name your package with respect to the Colorado School of Mines. An example of a unique packageId would be edu.mines.YOUR_NAME.modules. NOTE: If you have previous contributions to the SDK, ensure that your package name is different from your previous package names.
mvn archetype:generate \
-DgroupId=com.mycompany.module \
-DartifactId=my-module \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false
  1. If successful, this command has generated a new directory with the name of the artifactId. Enter this directory and locate the pom.xml file. Replace this file with this provided starter pom.xml (make sure to right click and select Save As, as otherwise your browser will try to render the xml).

  2. Modify this xml file to reflect your name, artifactId and groupId as above.

  3. Create a resources directory in src/main/ and place this skeleton manifest file (make sure to right click and select Save As) inside it so that your directory tree looks like the following diagram. (For an example manifest, see here.) Also, create a new directory called images/ in the resources folder. NOTE: All images used in your projects should be placed inside the images folder.

my-module
|-- pom.xml
`-- src
    |-- main
    |   |-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- module
    |   |               `-- Module.java
    |   `-- resources
    |       |-- manifest.xml
    |       `-- images
    |   
    `-- test
        `-- java
            `-- com
                `-- mycompany
                    `-- module
                        `-- ModuleTest.java
  1. Modify the manifest.xml to reflect your module's naming. At the least, you will need to change the package name and the class name to reflect your package and class names. If you were using the names above the package name would be "com.mycompany.module" and the class name would be "Module". Please refer to this page detailing how the module manifest works.
  2. Modify your main class file to extend from one of the Abstract Module classes.
  3. Add your module icon (thumbnail) into the images folder specified in step 4. A png format is preferred. Modify your manifest.xml file to the name of your icon, e.g. "icon.png". NOTE: DO NOT list the path as "images/icon.png". The SDK is configured to automatically look in the images folder for any image.
  4. If you have properly set up your pom.xml, you should be able to export your project into a JAR. See Exporting a Module Using Maven for the necessary steps.
  5. To run your JAR, follow the steps in our guide to create a runnable SDK folder.
Clone this wiki locally