1

Can you think of an elegant way to determine the package of a JAVA-class in SonarQube using the REST-API?

This snippet

http://myhost:9000/sonar/api/resources?resource=my.project%3Asimple.analysis&depth=-1&scopes=FIL

delivers a result containing

<lname>my/project/src/com/tobi/my/heros/SchmidtsKatze.java</lname>

I could XSLT it to com/tobi/my/heros/, but I wonder if there is a propper way? What do you think?

slartidan
  • 20,403
  • 15
  • 83
  • 131
Tobi
  • 71
  • 1
  • 5

1 Answers1

1

From the question you ask, I reckon you are using SonarQube 4.2 or later.

Since SQ 4.2, resource WS is fully language agnostic and deals only with files and directories, not Java class and packages anymore. Therefor, the information you are looking for is not available in plain in the WS response, you'll will have to do some XSLT or some other parsing and transformation.