|
22 | 22 |
|
23 | 23 | ## Section 1: Project Setup & Initial Exploration
|
24 | 24 |
|
25 |
| -**Goal:** Set up the basic project structure using the provided `README.md` and Copilot prompts, reinforcing basic interaction. |
| 25 | +**Goal:** Set up the basic project structure using the provided `README.md` and Copilot prompts, reinforcing basic interaction and critical review of build configurations. |
26 | 26 |
|
27 | 27 | ---
|
28 | 28 |
|
|
47 | 47 | ```
|
48 | 48 | 6. *(Optional)* Open the `README.md` from the *parent* directory in this new VS Code window for reference if needed.
|
49 | 49 |
|
50 |
| -### Exercise 1.2: Configure `pom.xml` with Copilot |
| 50 | +### Exercise 1.2: Configure `pom.xml` (Guided by User) |
51 | 51 |
|
52 |
| -* **Purpose:** To configure the project's build settings (Java version, testing framework) using Copilot prompts. |
53 |
| -* **Aim:** Use Copilot Chat to modify the `pom.xml` according to the `README.md` specifications. |
| 52 | +* **Purpose:** To configure the project's build settings (Java version, testing framework) by asking Copilot for specific configurations and critically reviewing the suggestions. |
| 53 | +* **Aim:** Practice guiding Copilot to generate specific `pom.xml` snippets and understand the importance of verifying AI-suggested build configurations. |
54 | 54 | * **Steps:**
|
55 | 55 | 1. Open the `pom.xml` file in VS Code.
|
56 | 56 | 2. Open the Copilot Chat view.
|
57 |
| - 3. Use the following prompts sequentially, reviewing and applying Copilot's suggestions (likely via diff views or copy-pasting): |
58 |
| - * `#file:pom.xml /explain Update the properties to set Java compiler source and target versions to 1.8.` |
59 |
| - * `#file:pom.xml /explain Add the necessary dependency for the JUnit 5 Jupiter engine (use a recent version like 5.8.2 or later). Ensure the scope is 'test'.` |
60 |
| - * `#file:pom.xml /explain Add and configure the maven-surefire-plugin (version 3.0.0-M5 or later) to work with JUnit 5.` |
61 |
| - * *(Optional)* `#file:pom.xml /explain Add the maven-assembly-plugin (version 3.3.0 or later) configured to create an executable JAR with dependencies. Set the main class in the manifest to com.example.App.` |
62 |
| - 4. Verify that the `<properties>`, `<dependencies>`, and `<build>` sections in `pom.xml` resemble the example in the `README.md`. |
| 57 | + 3. **Guide Copilot Step-by-Step:** Instead of asking Copilot to make changes directly, ask for the necessary XML snippets and review them carefully before adding them manually or using Edits mode. |
| 58 | + * **Java Version:** |
| 59 | + * Prompt: `#file:pom.xml /explain Show me the XML needed within the <properties> section to set the Java compiler source and target versions to 1.8.` |
| 60 | + * Review the suggested `<maven.compiler.source>1.8</maven.compiler.source>` and `<maven.compiler.target>1.8</maven.compiler.target>` properties. Add them inside the existing `<properties>` tags. |
| 61 | + * **JUnit 5 Dependency:** |
| 62 | + * Prompt: `#file:pom.xml /explain What is the Maven dependency XML snippet needed to add the JUnit 5 Jupiter engine for testing? Use a recent version like 5.8.2 or later and set the scope to 'test'.` |
| 63 | + * Review the suggested `<dependency>` block. Verify the `groupId`, `artifactId`, `version`, and `scope`. Add it inside the `<dependencies>` section. |
| 64 | + * **Surefire Plugin:** |
| 65 | + * Prompt: `#file:pom.xml /explain Show me the XML configuration for the maven-surefire-plugin (version 3.0.0-M5 or later) needed within the <build><plugins> section to ensure it works correctly with JUnit 5.` |
| 66 | + * Review the suggested `<plugin>` configuration. Add it inside the `<plugins>` section (create `<build><plugins>` if they don't exist). |
| 67 | + * **(Optional) Assembly Plugin:** |
| 68 | + * Prompt: `#file:pom.xml /explain Show me the XML configuration for the maven-assembly-plugin (version 3.3.0 or later) to create an executable JAR with dependencies. How do I configure the main class as com.example.App?` |
| 69 | + * Review the suggested `<plugin>` configuration carefully, especially the `<mainClass>` element and `<descriptorRef>`. Add it inside the `<plugins>` section. |
| 70 | + 4. **Verification and Warning:** |
| 71 | + * Compare your final `pom.xml` structure against the example in the `README.md`. |
| 72 | + * **Critical Warning:** Build files like `pom.xml` define crucial aspects of your project (dependencies, versions, build process). While Copilot can provide correct snippets, it might suggest outdated versions, incompatible configurations, or unnecessary elements. **Always critically review AI suggestions for `pom.xml`. Verify dependency versions against official repositories (like Maven Central) and plugin configurations against their official documentation.** Do not blindly accept changes to your build configuration. |
| 73 | + 5. Save the `pom.xml` file. |
63 | 74 |
|
64 | 75 | ### Exercise 1.3: Create Basic App and Test Stubs with Copilot
|
65 | 76 |
|
|
338 | 349 | * **Purpose:** To create unit tests for the core game logic classes.
|
339 | 350 | * **Aim:** Use the `/tests` command with the active custom test generation instructions to test `GameState` and potentially parts of `GameEngine`.
|
340 | 351 | * **Steps:**
|
341 |
| - 1. Open `GameState.java`. |
| 352 | + 1. Open `GameState.java` (or the file created by the agent in Exercise 4.3). |
342 | 353 | 2. In Copilot Chat, prompt: `# (select GameState.java) /tests Generate JUnit 5 tests for the public methods of this class (like constructor, addCorrectGuess, addIncorrectGuess, isWon, isLost). Follow the project's test guidelines.`
|
343 | 354 | 3. Copilot should create/update `GameStateTest.java`. Review the generated tests:
|
344 | 355 | * Are they JUnit 5?
|
|
370 | 381 | * **Purpose:** To replace the hardcoded word list with logic to read from the provided `nouns`/`verbs` files.
|
371 | 382 | * **Aim:** Use Copilot (Ask, Edits, Completion), guided by custom instructions for I/O error handling, to implement file reading in `WordSource.java`.
|
372 | 383 | * **Steps:**
|
373 |
| - 1. Open `WordSource.java`. |
| 384 | + 1. Open `WordSource.java` (or the relevant file created by the agent). |
374 | 385 | 2. Use Copilot Chat or Edits mode: `# (select WordSource.java) /explain Modify this class to read words from text files named 'nouns.txt' and 'verbs.txt' located in the project root (or a specified resources directory). Load all words into a single list. Handle potential FileNotFoundException and IOException according to the project's error handling guidelines (use try-with-resources, log errors). Update the word selection method to use this list.`
|
375 | 386 | 3. Review and refine the generated code, ensuring robust file handling.
|
376 | 387 |
|
|
0 commit comments