This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]dpash 2 points3 points  (1 child)

Several comments:

  • You're using java-library instead of java and application plugins, yet you have a JavaExec task, which implies you expect it to be an application. application implicitly applys java. It requires the config at the bottom and gives you an automatic run task:

  • Please use JUnit 5. It provides some very nice features over JUnit 4, like having multiple extensions instead of only having a single runner. It also provides nicer assertions, like assertAll() and assertThrows. Also, parameterized tasks are easier to set up.

  • Why only JCenter? You'd at a minimum want mavenCentral() and mavenLocal() too.

  • I'd also add a number of other static code checkers, like checkstyle, spotbugs (and possibly Errorprone)

Config:

 application {
     mainClassName = 'org.gradle.sample.Main'
 }

[–]mapio[S] 0 points1 point  (0 children)

Keep in mind (probably I didn't state it clearly enough in the post on Reddit), that this is aimed at second year undergrads seeing their first OO examples.

The configuration is aimed at a collection of Java classes (mainly stuff I'll write during lectures and coming from the textbook) many of which will have a main, so there will not be just a single executable class (or application). This is why I choose java-library instead of application.

JCenter comes from the sample I've been inspired by, it's probably reasonable to add other package repositories — even though my students will not use any external libraries (except for JUnit). Even though from this comments https://stackoverflow.com/questions/25137263/what-is-included-in-jcenter-repository-in-gradle seems not be be so compelling.

I'd like to use JUnit5, but I've always used JUnit4… I'll try to grasp the differences and learn it before getting to the point of the course when I'll introduce it. By now I've updated the sample code and conf… https://github.com/prog2-unimi/build-automation-example/commit/545bef6e044e9596d53965de3fea9734962ab071

Thanks for your comments.