SonarQube PHP
  1. SonarQube PHP
  2. SONARPHP-7

PHP Plugin poorly support ant build files

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.4
    • Fix Version/s: 0.6
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Plugin at the moment has limited support for ant build files. For example it completely ignores sonar.binaries property and when a project is analysed with ant build directory always defaults to 'target' subdirectory in given working directory.

        Activity

        Hide
        Fabrice Bellingard added a comment -

        Hi Sebastian,
        what is "sonar.binaries" supposed to be used for in the PHP world?
        Concerning the build directory, I'm gonna have a look at it.

        Show
        Fabrice Bellingard added a comment - Hi Sebastian, what is "sonar.binaries" supposed to be used for in the PHP world? Concerning the build directory, I'm gonna have a look at it.
        Hide
        Sebastian Marek added a comment -

        Hello Fabrice,

        I understand that in JAVA world this is where compiled packages go. As in PHP we don't compile there is nothing to store there, but still we need a way to configure where we want to store all the log/xml files (a alternative location for default target directory).

        I hope this helps.

        Show
        Sebastian Marek added a comment - Hello Fabrice, I understand that in JAVA world this is where compiled packages go. As in PHP we don't compile there is nothing to store there, but still we need a way to configure where we want to store all the log/xml files (a alternative location for default target directory). I hope this helps.
        Hide
        Fabrice Bellingard added a comment -

        Hi Sebastian,

        the xml log files are just temporary files generated during the analysis by third-party tools so that Sonar can read them and push them in the DB, why would you want to customize the path where those temporary files are stored? You want to reuse them?

        Show
        Fabrice Bellingard added a comment - Hi Sebastian, the xml log files are just temporary files generated during the analysis by third-party tools so that Sonar can read them and push them in the DB, why would you want to customize the path where those temporary files are stored? You want to reuse them?
        Hide
        Sebastian Marek added a comment -

        Sonar is often used in conjunction with a build server, and it is build server that generates XML files. There is no point then getting sonar to do that again as we can reuse them. The challenge here is to be able to configure Sonar to look at the location where the files have been stored in the first place by CI server.

        Show
        Sebastian Marek added a comment - Sonar is often used in conjunction with a build server, and it is build server that generates XML files. There is no point then getting sonar to do that again as we can reuse them. The challenge here is to be able to configure Sonar to look at the location where the files have been stored in the first place by CI server.
        Hide
        Fabrice Bellingard added a comment -

        Well, I perfecty undestand this, and this is why for every tool, you have 3 properties that allow you to reuse existing reports.

        For instance, for PHP CodeSniffer:

        <property name="sonar.phpCodesniffer.analyzeOnly" value="true" />
        <property name="sonar.phpCodesniffer.reportFileRelativePath" value="../../logs" />
        <property name="sonar.phpCodesniffer.reportFileName" value="cs-report.xml" />
        

        This will tell Sonar to get the "cs-report.xml" report file located in the "logs" folder of your project. You have to use "../.." as the path is relative to the temporary working directory, which is ".sonar/target" when using Ant.

        Don't those properties meet your needs?

        Show
        Fabrice Bellingard added a comment - Well, I perfecty undestand this, and this is why for every tool, you have 3 properties that allow you to reuse existing reports. For instance, for PHP CodeSniffer: <property name= "sonar.phpCodesniffer.analyzeOnly" value= "true" /> <property name= "sonar.phpCodesniffer.reportFileRelativePath" value= "../../logs" /> <property name= "sonar.phpCodesniffer.reportFileName" value= "cs-report.xml" /> This will tell Sonar to get the "cs-report.xml" report file located in the "logs" folder of your project. You have to use "../.." as the path is relative to the temporary working directory, which is ".sonar/target" when using Ant. Don't those properties meet your needs?
        Hide
        Fabrice Bellingard added a comment -

        And don't forget that you can configure those properties in the general settings page of the PHP plugin in Sonar web UI, instead of passing them to every Ant build script (which is annoying when you have a convention that is followed by hundreds of projects).

        Show
        Fabrice Bellingard added a comment - And don't forget that you can configure those properties in the general settings page of the PHP plugin in Sonar web UI, instead of passing them to every Ant build script (which is annoying when you have a convention that is followed by hundreds of projects).
        Hide
        Sebastian Marek added a comment -

        Yes, still it would be good to be able to have an option in ant to set up the build dir, like you can do it in maven pom file. I understand at the moment, you can only change the location of .sonar subir, but it still will the "target" dir the will be used by default to store the xml files.

        I guess, if you agree to do something with it, it wil be a low priority anyway, as there are workarounds to achieve it.

        Show
        Sebastian Marek added a comment - Yes, still it would be good to be able to have an option in ant to set up the build dir, like you can do it in maven pom file. I understand at the moment, you can only change the location of .sonar subir, but it still will the "target" dir the will be used by default to store the xml files. I guess, if you agree to do something with it, it wil be a low priority anyway, as there are workarounds to achieve it.
        Hide
        Fabrice Bellingard added a comment -

        I improved the documentation on the Ant page of the PHP Wiki page in order to show a clean Ant script example that shows how to specify reuse report paths.

        Show
        Fabrice Bellingard added a comment - I improved the documentation on the Ant page of the PHP Wiki page in order to show a clean Ant script example that shows how to specify reuse report paths.
        Hide
        Fabrice Bellingard added a comment -

        I will resolve this ticket, as changing the build directory of the Ant task is not an issue on the PHP plugin side.

        Just for information, Evgeny confirmed me that this is not possible to modify the ".sonar/target" directory. So if you want to migrate from Maven to Ant for your projects, then the only solution I see is to add a task (after the Sonar one) that moves the report from ".sonar/target/logs" to "build/logs".

        Show
        Fabrice Bellingard added a comment - I will resolve this ticket, as changing the build directory of the Ant task is not an issue on the PHP plugin side. Just for information, Evgeny confirmed me that this is not possible to modify the ".sonar/target" directory. So if you want to migrate from Maven to Ant for your projects, then the only solution I see is to add a task (after the Sonar one) that moves the report from ".sonar/target/logs" to "build/logs".

          People

          • Assignee:
            Fabrice Bellingard
            Reporter:
            Anonymous
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: