You could use something like Class.forName() to check for the existence of the plugin on the classpath and conditionally then use plugins.withType() to register some configuration if the class exists.
1 Like