Access CoreProperties in custom plugin

Hey there,

in a custom plugin with a PostProjectAnalysisTask we’d like to access the CoreProperties.LINKS_SOURCES and we wonder how to do that.

Thanks in advance. Regards, Matt

Can it be that I’m confronted with this bug and there is simply no way to get the project settings :disappointed_relieved:

Hello @mkappeller,

Welcome to the community!

I think there is a one way to get this data:

  1. You need to create a scanner extension point (a class which extends org.sonar.api.batch.sensor.Sensor), this class will read CoreProperties.LINKS_SOURCES property as it should be available at that level
  2. Store value of that property into analysis context using SensorContext::addContextProperty
  3. Read value of that property in your PostProjectAnalysisTask class using context.getProjectAnalysis().getScannerContext().getProperties()

I hope that helps

Hey thanks Jacek for the reply. I actually ended up doing something similar but gathered the scm url manually in the Sensor… but you’re right it’s available in context.config() .get(LINKS_SOURCES) directly. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.