Accessing gradle properties in java jar

Hi Team,

I am exposing my jar file to other teams. Is it possible during build my jar can read the gradle properties defined in users Like I want use project name and cmdb id to read from gardle file so internally my jar can push that information to elastic search?

Do you mean you want to include that information in the MANIFEST.MF? The jar task has a manifest configuration closure:

jar {
  manifest {
    attributes 'Implementation-Title': 'ProVerbial',
    'Implementation-Version': "Integrierte Version ${project.version}",
    'Implementation-Vendor': project.proVerbialImplementationVendor,
    'Built-from': project.built_from_revision

The project.x properties come from, the command line etc.

Hi Sjbufton,

thanks for you reply. No my requirement is, I am devloping a jar which other users will be using in there say complile ‘xxxx.myjar’. Inside my jar code is they any way I can pass the cmdb id and project name of gradle project which third party user is buidling using my jar.

Is your jar a build plugin, or simply a dependency included in some other project? If it is a plugin, of course it can read the build properties. If it’s simply a dependency, there is no code which will be activated as part of the build, so no.