# “Do I need these instructions?”

You only need these instructions when it comes to test that your code runs using the Maven wrapper that was provided to you—and you want to test that from within Eclipse.

You are encouraged to just run the test cases using the JUnit GUI tool in Eclipse, as this will be more convenient and easier to navigate through the test cases. In this case, you will be ignoring the Maven wrapper provided.

However, when it comes time to submitting your assignments, you still need to make sure your assignment runs using the provided Maven wrapper. In this case, either follow the instructions below to use the Maven wrapper from within Eclipse, or simply use the Maven wrapper from the command line like was explained here.

# “But Eclipse already has Maven built into it!”

Correct! While Eclipse already has Maven built in, we want to make sure we use the Maven wrapper provided in the assignment repositories. This ensures that we are all using the same Maven version to compile and test the code.

This is similar logic to why we would want to use the Maven wrapper from the command line, rather than relying on whatever Maven version developers would install themselves.

# Using the Maven Wrapper (as an “External Program”) in Eclipse

As you might recall, the Maven wrapper is that mvnw file (if you are on Unix/MacOS) or mvnw.cmd (if you are on Windows). As such, we need to tell Eclipse to use this file. From Eclipse’s point of view, the Maven wrapper will be seen as an “external program”.

# Setting up the Maven wrapper as an External Tool

#### When you need to run the Maven wrapper again, remember it’s in the External Tools section.

The above instructions were to make a single run configuration, namely Maven’s test phase. You will notice we specified clean test, so that the old compiled code is deleted before running the test cases again. It’s just safer, to be sure you are always running the latest code.

Since this configuration is using test, it will do the compile automatically. Keep this in mind if you see a BUILD FAILURE—it might be due to your code not compiling, and not necessarily that your test cases failed!

If you would like to have separate run configurations for each of the phases (not essential), you can if you want. Repeat the instructions above for each phase you want. All you would need to change is the Name of the configuration (Step 12) and the Arguments (Step 20). For example:

• Maven compile:
• Name = Maven wrapper compile
• Arguments = clean compile
• Maven test: (i.e. what we have already done above)
• Name = Maven wrapper test
• Arguments = clean test
• Maven clean:
• Name = Maven wrapper clean
• Arguments = clean