Lab: Report Deployment

Steven J Zeil

Last modified: Mar 29, 2022
Contents:

Abstract

In this lab, you will automate report generation and deployment (to GitHub Pages) for your project.

Make sure that you have your GitHub repository from this earlier assignment. The project must include a working Gradle wrapper, and a gradle build that can compile and run tests. (You need not pass all of the tests.)

1 GitHub Setup

Rebuild your project and examine your working directory again. In build/reports/tests/test, you should find a nice little collection of files providing a web-ready summary of your unit test performance.

Then try gradle javadoc. You should find additional web pages now in build/docs.

Suppose that we wanted to put that up on a project website…

  1. Make sure that all of your project files are committed and pushed or set to be ignored.
  2. Create a new directory src/main/html to hold new web content.
  3. In that directory, create a file named index.md with the following content:
    # Project Reports
    
    Your Name
    
    * [Tests](./reports/tests/test/)
    * [JavaDoc](./reports/javadoc/)
    
  4. Commit and push your new file.

  5. On GitHub, create a new public repository. We will call this your “website repository”.
  6. On GitHub, enter your new repository’s Settings area. Select Pages.

    Under Source, select your main branch. Leave the folder at root.

    Click Save.

  7. Optionally, choose a Theme for your website. This theme will determine the appearance of Markdown files on your site.

  8. Commit and push to that repository a Markdown file named index.md containing simply the word “Hello”.

  9. Use a web browser to verify that you now have a web site at https://yourGitHubLogin.github.io/yourProjectName/

    You should recognize your “index” page.

2 Report Generation

Next, you will add the steps to automatically publish your test and javadoc reports.

  1. Return to your gradle project.
  2. Modify your build.gradle file to add a task named reports. The reports task should ensure that both the test and javadoc tasks have been executed, and then
    • copy the build/docs/ directory, and all its contents, to a new build/reports/javadoc/ directory.
    • copy all files and directories from src/main/html/ directory to the reports/ directory.
  3. Test your new task by running

    gradle reports
    

    and verify that all of your content has moved into the build/reports directory.

  4. Modify your build.gradle file to add a task named deployReports. This task should

    • Guarantee that the reports task has been run.
    • Use git to transfer the reports/ directory to your website repository.
  5. Test your new tasks by running

    gradle deployReports
    
  6. Use a web browser to verify that your website at https://yourGitHubLogin.github.io/yourProjectName/ has been updated. You should immediately see that your index page no longer merely says “Hello”. Follow the links to observer your reports.

    Again, you should recognize your “index” page. Verify that the links now work and lead to the appropriate reports.

  7. You can play with this as you like. Maybe add some additional content to the src/main/html directory, change the number of unit tests, or alter the JavaDoc documentation in your .java files. Then see if yo can observe the changes after running the deployReports task again.