How to add third party library to the classpath of a plugin?

I am use the plugin com.gradle.plugin-publish to create a plugin. I want use/bundle a third party library with my plugin? Is this possible with com.gradle.plugin-publish?

In the original plugins I have see a foo-classpath.properties in the root of the jar files. Can I set it with this plugin?

A workaround is to extract the third party jar file and copy the content in the plugin. This sound not a good idea.

Or can I setup a maven dependency for my plugin?

Hi @Horcrux7

It’s not clear what you mean when referring to “original plugins”. Can you please elaborate.

I means the plugins that are bundle with Gradle.

I have solve it with:

private ClassLoader getClassLoader( Project project ) throws MalformedURLException {
    if( lauch4jClassLoader == null ) {
        String configName = "setupLaunch4j";
        Configuration config = project.getConfigurations().create( configName );
        config.setVisible( false );
        config.setTransitive( false );
        DependencyHandler dependencies = project.getDependencies();
        dependencies.add( configName, "net.sf.launch4j:launch4j:3.8.0" );
        dependencies.add( configName, "net.sf.launch4j:launch4j:3.8.0:workdir-win32" );
        dependencies.add( configName, "com.thoughtworks.xstream:xstream:1.4.8" );

        ArrayList<URL> urls = new ArrayList<>();
        for( File file : config.getFiles() ) {
            if( file.getName().endsWith( ".jar" ) ) {
                urls.add( file.toURI().toURL() );
            }
        }
        lauch4jClassLoader = new URLClassLoader( urls.toArray( new URL[urls.size()] ), getClass().getClassLoader() );
    }
    return lauch4jClassLoader;
}

That is the normal way. Build script authors might need to add jcenter to buildscript repositories {}, but that is acceptable.