ProjectBuilder not applying plugins nor repositories

I am trying to use ProjectBuilder to test my custom plugin which applies Maven authentication credentials (from ~/.m2/settings). However, after using ProjectBuilder to build a Project that Project does not have any plugins, repos, etc associated with it.

Am I missing something in the usage of ProjectBuilder?

Your expectation sounds suspect. The ProjectBuilder should yield an instance that implements the Project interface which you can then work with to test your plugin. You need to execute code that adds plugins, repositories, etc. to the Project built by ProjectBuilder.

I would expect code along these lines of:

Project project = ProjectBuilder.builder().build(); // No repositories or plugins applied
project.getPluginManager().apply(CustomPlugin.class); // CustomPlugin applied
project.getRepositories().jcenter(); // jcenter() now added to repositories

I see. I had thought that org.gradle.testfixtures.ProjectBuilder#withProjectDir read the build.xml from that directory, but as you point out that is not accurate. Thanks

The plugin I am trying to test uses Project#afterEvaluate.

#afterEvaluate does not seem to be triggered for me. Or maybe it is triggered during ProjectBuilder#build which is unfortunately too early if the test needs to configure the project through Project instead of ProjectBuilder. Any pointers?