Configuring the gradle cpp plugin from within a custom plugin

I am currently creating a custom Gradle plugin where the intention is to apply the cpp plugin on the project that the plugin is applied to.

Once the cpp plugin is applied I want to be able to set source sets on the cpp plugin to define standard layouts for source files etc. This of course is quite simple when applied to a project in a DSL but appears to be difficult when attempting this via a Java based plugin.

The purpose behind this is that I want to be able to have a custom plugin that is internal to my code base that allows me to apply a plugin to a project that sets all of the cpp source sets and binary / library / test settings that I want without me having to set all of these on the multitude of projects (microservices) that I have within the code base.

So far, I have been able to create the custom plugin such that it can be included in another project and the custom plugin has the cpp plugin applied to it, but as far as configuring the cpp plugin goes, I am at a bit of a loss.

My current code is below:

class customPlugin implements Plugin<Project> {
void apply(Project project) {
    project.setBuildDir(project.getRootProject().getBuildDir())

    project.getPluginManager().apply "cpp"
    CppPlugin nativeComponentPlugin = project.getPlugins().getPlugin('cpp')  //I can't do anything useful with this object

   project.task(project.getName()) {
        doLast {
            println 'Project ' + project.getName()
        }
    }
}