Lab: Report Deployment
Steven J Zeil
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…
- Make sure that all of your project files are committed and pushed or set to be ignored.
- Create a new directory
src/main/html
to hold new web content. - In that directory, create a file named
index.md
with the following content:# Project Reports Your Name * [Tests](./reports/tests/test/) * [JavaDoc](./reports/javadoc/)
-
Commit and push your new file.
- On GitHub, create a new public repository. We will call this your “website repository”.
-
On GitHub, enter your new repository’s
Settings
area. SelectPages
.Under
Source
, select yourmain
branch. Leave the folder at root.Click
Save
. -
Optionally, choose a Theme for your website. This theme will determine the appearance of Markdown files on your site.
-
Commit and push to that repository a Markdown file named
index.md
containing simply the word “Hello”. -
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.
- Return to your gradle project.
- Modify your
build.gradle
file to add a task namedreports
. Thereports
task should ensure that both thetest
andjavadoc
tasks have been executed, and then- copy the
build/docs/
directory, and all its contents, to a newbuild/reports/javadoc/
directory. - copy all files and directories from
src/main/html/
directory to thereports/
directory.
- copy the
-
Test your new task by running
gradle reports
and verify that all of your content has moved into the
build/reports
directory. -
Modify your
build.gradle
file to add a task nameddeployReports
. This task should- Guarantee that the
reports
task has been run. - Use git to transfer the
reports/
directory to your website repository.
- Guarantee that the
-
Test your new tasks by running
gradle deployReports
-
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.
-
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 thedeployReports
task again.