# Best of both worlds between "buildSrc" and JAR

**URL:** <https://discuss.gradle.org/t/best-of-both-worlds-between-buildsrc-and-jar/15070>\
**Category:** Help/Discuss\
**Created:** [March 9, 2016, 6:28pm UTC](https://discuss.gradle.org/t/best-of-both-worlds-between-buildsrc-and-jar/15070 "2016-03-09T18:28:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocroquette](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@ocroquette](https://discuss.gradle.org/u/ocroquette)\
**Post date:** [March 9, 2016, 6:28pm UTC](https://discuss.gradle.org/t/best-of-both-worlds-between-buildsrc-and-jar/15070/1 "2016-03-09T18:28:20Z")

</div>

Hi,

I have a pretty complex plugin that is currently located in “buildSrc”, and which is working fine. Currently, it’s very convenient to modify it, since it’s (re)compiled on the fly automatically by Gradle as required. The problem is that this takes at least 10 seconds, even if there are no changes.

I know I could make a JAR out of it, and that starting the build would be much faster, however, I would when changes would be necessary, the naive workflow would be quite cumbersome and slow (modify, create JAR, copy JAR in place, start build) compared to the current one (modify, start build). Is there a better alternative than this naive workflow?

Is there way to decide at runtime whether to use the JAR or buildSrc? That would make things much easier, because then I could choose to use buildSrc during the development cycles, and when I am done, deploy the JAR and start to use it. However, it seems the handling of “buildSrc” is hard-coded in Gradle and cannot be modified. Or can it?

Thanks,  
Olivier

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [March 9, 2016, 7:34pm UTC](https://discuss.gradle.org/t/best-of-both-worlds-between-buildsrc-and-jar/15070/2 "2016-03-09T19:34:48Z")

</div>

> [@ocroquette](#):
>
> The problem is that this takes at least 10 seconds, even if there are no changes.

Why is that? Have you profiled it? Sounds very high.

> [@ocroquette](#):
>
> I would when changes would be necessary the naive workflow would be quite cumbersome and slow

You have several options:

- use [TestKit](https://docs.gradle.org/current/userguide/test_kit.html) to run your build with the version of the plugin currently under development
- do what you described, but automate the copying of the jar to the correct location
- copy the plugin code back to buildSrc while you work on the fix. When the fix is ready, copy back

---

<div class="post-metadata">

**Author:** ![ocroquette](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@ocroquette](https://discuss.gradle.org/u/ocroquette)\
**Post date:** [March 14, 2016, 8:07pm UTC](https://discuss.gradle.org/t/best-of-both-worlds-between-buildsrc-and-jar/15070/3 "2016-03-14T20:07:02Z")

</div>

No, I didn’t profile it, but it doesn’t surprise me, since I don’t use the daemon due to a few issues with it, so a new VM is started each time. Then it needs to compile about 30 Groovy files.

I was hoping I could avoid copying and renaming files or directories. It is actually surprisingly inflexible from Gradle to unconditionally load from buildSrc, and that this name is hard-coded. I understand this mechanism has to be easy in the simple situations, but it would also make sense to be able to customize it, like with so many aspects of Gradle.

I will have a look at TestKit, thanks for your time.

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [March 14, 2016, 9:55pm UTC](https://discuss.gradle.org/t/best-of-both-worlds-between-buildsrc-and-jar/15070/4 "2016-03-14T21:55:06Z")

</div>

It will become more flexible in the future, but for now the options listed above are the ways you can go.
