Creating a New Module Project - struct-by-lightning/wpi-suite GitHub Wiki

This page contains instructions for creating a new Eclipse Project to hold a new WPISuite module. Note: In the instructions below, replace ModuleName with the name of your new module.

New Java Project

  1. Open the File menu in Eclipse and create a new Java Project.
  2. Name the project ModuleName.
  3. DO NOT use the default locations for the project. Your project needs to be inside your local git repository, at the same level as the other projects. The path might be something like ~/SoftEng/wpi-suite-tng/ModuleName.
  4. Click Next and open the Projects tab.
  5. Click Add and check off the Janeway, Network, and WPISuite-Interfaces projects.
  6. Click OK, and Finish.

Configure Build Settings

You need to add a build.xml file to the root of your Eclipse project so that it will build correctly.

  1. Copy and paste the build.xml file from the root of the DefectTracker project into your project.
  2. Right-click on the build.xml file in your project and click open with --> text editor.
  3. Use Find/Replace in the file to replace all instances of DefectTracker with ModuleName
  4. Save and close build.xml

Next, you need to tell your Eclipse project to use the new build.xml file.

  1. Right-click on your new project in the project explorer and click Properties.
  2. Open the Builders section and click New.
  3. Select Ant Builder as the type and click OK.
  4. Under the Buildfile field, click Browse Workspace and select the build.xml file under your project and click OK.
  5. Under the Refresh tab, choose to refresh the entire workspace and subfolders
  6. Click Apply to add the new builder.

Finally, you need to modify the dependencies.xml file that is in the root of the git repository.

  1. Open dependencies.xml in a text editor and find the <target name="depend.all" line. Add to the depends list depend.ModuleName
  2. Next, add a new target at the bottom of the file after the other targets but before the </project> tag. The new target should look like this:
<target name="depend.ModuleName"
	depends="depend.Janeway">
	<ant dir="${dependencies.basedir}/ModuleName"
		target="${dependency.target}"
		inheritAll="false"/>
</target>
  1. Finally, modify the depend.WPISuite target so that it depends on your module:
<!-- Note that WPISuite depends on DefectTracker because of the lack of dynamic loading -->
<target name="depend.WPISuite"
	depends="depend.WPISuite-Interfaces, depend.DefectTracker, depend.ModuleName"> <!-- depend.ModuleName was added to this line -->
	<ant dir="${dependencies.basedir}/Core/WPISuite"
		target="${dependency.target}"
		inheritAll="false"/>
</target>

Modify .gitignore to ignore your project jar file

When your new project is built, it will generate a .jar file that is automatically placed within the core project's lib directory (/Core/WPISuite/WebContent/WEB-INF/lib/ModuleName.jar). You need to tell git not to commit this to the repository.

  1. Open the .gitignore file that is in the root of the repository, note this is a hidden file so you might not see it in your directory listing.
  2. At the very bottom of the file add a new line with the path to your project's jar file: /Core/WPISuite/WebContent/WEB-INF/lib/ModuleName.jar
  3. Save and close the file.

Add a manifest.txt file to your project

In order for the Janeway client to load your module, you need to provide a manifest.txt file in the root of your project that identifies the class that should be loaded for your module. To do this:

  1. Right-click on your project in the Package Explorer, open the New submenu, and click File.
  2. Place the file in the root of your module project and name it manifest.txt
  3. Place one line in the file, which is the directive module_class followed by the fully qualified class name of the class in your module that implements IJanewayModule. An example file is below.
module_class edu.wpi.cs.wpisuitetng.modules.defecttracker.JanewayModule

Modify the modules.conf file in the Janeway project

Note: This step is not necessary if you followed the instructions for configuring your build settings above.

If you modify your project build settings to build the jar file for your project into another location. You need to tell Janeway where to look for the jar. You can add a module directory by doing the following:

  1. Open the modules.conf file (located in the root of the Janeway project)
  2. If your JAR file is not located in one of the module_path directories, add the directory containing it to the list.
  3. Save the config file and the next time you launch Janeway your module should load.
⚠️ **GitHub.com Fallback** ⚠️