Unit testing Custom Tasks in Java

I am writing some custom tasks in Java. I am having a hard time finding any code examples. All the ones I have found are in groovy. I wrote a junit test and I am trying to figure out how to call my custom task. Any suggestions?

Project project = ProjectBuilder.builder().build();
Task task = project.task(“FileHeaderVerify”, ???);

I wouldn’t use ProjectBuilder for testing that your task works. It doesn’t simulate enough of a real Gradle runtime to make it work.

Take a look at this guide (specifically the functional test section): https://guides.gradle.org/testing-gradle-plugins/#functional-tests

I wouldn’t personally write functional tests in Java, but there’s an example bundled in the Gradle distribution: