Get project(":buildSrc") object

Hi
Is it possible to get an object of class Project for :buildSrc subproject (or whatever it is) from inside my Plugin.apply which itself is inside of buildSrc dir?

buildSrc is a very special thing.
You cannot access it from the outer build.
It is run standalone completely separated.

But if you elaborate on why you want to do that,
there is probably a better way to achieve what you want.

Hi, Björn
I already have a workaround but it’s not that pretty. I thought maybe there is a way to make it better.
Just hardcoded the path to the jar file, which is built by a subproject inside a buildSrc. It’s a javaagent which I need my app to be run with

buildSrc is not meant for anything that is necessary to run your project with, it is only meant for things to run your build with.
Actually I don’t use buildSrc at all, but prefer using an included build, for example in gradle/build-logic/.
An included build can provide both, build logic and also project logic, so you might also consider switching to composite builds, then you can probably easily and cleanly do it by just declaring a respective dependency on the artifact with the Java agent.

Maybe I would. I thought composite builds aren’t finished yet

Which software is ever finished?
But at least they were promoted to stable with the 5.0 release in November 2018.

Oh, I thought they were added much more recently. Somehow I’ve missed it

They were initially introduced in Gradle 3.1 in September 2016

the time flies so fast :slight_smile:

2 Likes