# Can plugins with JavaExec tasks add code from the plugin itself to the classpath?

**URL:** <https://discuss.gradle.org/t/can-plugins-with-javaexec-tasks-add-code-from-the-plugin-itself-to-the-classpath/4165>\
**Category:** Old Forum Archive\
**Created:** [November 11, 2014, 9:26am UTC](https://discuss.gradle.org/t/can-plugins-with-javaexec-tasks-add-code-from-the-plugin-itself-to-the-classpath/4165 "2014-11-11T09:26:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![August\_Lilleaas](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/august_lilleaas/32/803_2.png) [@August\_Lilleaas](https://discuss.gradle.org/u/August_Lilleaas)\
**Post date:** [November 11, 2014, 9:26am UTC](https://discuss.gradle.org/t/can-plugins-with-javaexec-tasks-add-code-from-the-plugin-itself-to-the-classpath/4165/1 "2014-11-11T09:26:00Z")

</div>

My plugin defines a JavaExec tasks. It adds the “runtimeClasspath” of the main source set, and the “compileClasspath” and “.getOutput()” of a source set the plugin creates in the project.

I also want src/main/groovy from the actual plugin code itself to be added to the classpath. Since the plugin is a “buildscript” dependency, it is not present in the runtimeClasspath of the main source set.

How do I add the plugin itself to the classpath of my JavaExec task?

Here’s my code so far. [https://gist.github.com/augustl/c0fdf2c7ce9e388c22c6](https://gist.github.com/augustl/c0fdf2c7ce9e388c22c6)

---

<div class="post-metadata">

**Author:** ![August\_Lilleaas](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/august_lilleaas/32/803_2.png) [@August\_Lilleaas](https://discuss.gradle.org/u/August_Lilleaas)\
**Post date:** [November 12, 2014, 9:50am UTC](https://discuss.gradle.org/t/can-plugins-with-javaexec-tasks-add-code-from-the-plugin-itself-to-the-classpath/4165/2 "2014-11-12T09:50:00Z")

</div>

Figured it out on my own.

To access the classpath of the plugin, use ‘project.buildscript.configurations.classpath’.

This is not _really_ the classpath of the plugin, it’s the classpath of the entire buildscript step. But that’s where my plugin lives, so it shouldn’t be a problem for me to use that classpath.
