SonarQube Plugins
  1. SonarQube Plugins
  2. SONARPLUGINS-1187

Allow configuration via sonar-project.properties rather than pom.xml

    Details

    • Number of attachments :
      0

      Description

      I would like to be able to configure the Web Plugin via a sonar-project.properties file rather than a pom.xml.

      Our project doesn't use Maven, so I'd prefer not to create a pom. We only use the standalone runner or the Ant task, and our Java projects are all configured via sonar-project.properties files. I would like to configure web projects that way as well, for consistency and to avoid confusing people.

      Currently trying to run sonar-runner with no pom.xml, only a sonar-project.properties, yields the following error:

      Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: java.lang.NullPointerException
      	at org.sonar.runner.Main.delegateExecution(Main.java:114)
      	at org.sonar.runner.Main.execute(Main.java:67)
      	at org.sonar.runner.Main.main(Main.java:48)
      Caused by: java.lang.NullPointerException
      	at org.sonar.plugins.web.ProjectConfiguration.configureSourceDir(ProjectConfiguration.java:46)
      	at org.sonar.plugins.web.WebSourceImporter.analyse(WebSourceImporter.java:48)
      	at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:58)
      	at org.sonar.batch.phases.Phases.execute(Phases.java:80)
      	at org.sonar.batch.ProjectBatch.execute(ProjectBatch.java:59)
      	at org.sonar.batch.Batch.analyzeModule(Batch.java:164)
      	at org.sonar.batch.Batch.analyzeModules(Batch.java:82)
      	at org.sonar.batch.Batch.execute(Batch.java:62)
      	at org.sonar.runner.Launcher.executeBatch(Launcher.java:60)
      	at org.sonar.runner.Launcher.execute(Launcher.java:53)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.sonar.runner.Main.delegateExecution(Main.java:111)
      	... 2 more
      

        Activity

        Hide
        Matthijs Galesloot added a comment -

        Tested WebPlugin 1.1 with standalone runner and the Ant task. Both work fine.

        Show
        Matthijs Galesloot added a comment - Tested WebPlugin 1.1 with standalone runner and the Ant task. Both work fine.
        Hide
        Gordon McNaughton added a comment -

        Sounds good, thanks for testing this!

        Sorry, I'm new to the project so this may be a dumb question, but does 1.1 have a slated release date? Or should I just grab the latest sources and compile for myself?

        Show
        Gordon McNaughton added a comment - Sounds good, thanks for testing this! Sorry, I'm new to the project so this may be a dumb question, but does 1.1 have a slated release date? Or should I just grab the latest sources and compile for myself?
        Hide
        Matthijs Galesloot added a comment -

        v 1.1 has been been voted in the last few days by the committers on the dev mailing list. Release will be done today.

        Show
        Matthijs Galesloot added a comment - v 1.1 has been been voted in the last few days by the committers on the dev mailing list. Release will be done today.
        Hide
        Gordon McNaughton added a comment -

        I tried again with Web Plugin 1.1, Sonar 2.8, and Sonar Runner 1.0, but still get the issue. The stack trace has changed though. If you only have a sonar-project.properties file, and not a pom.xml, sonar-runner crashes with the following:

        Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: java.lang.NullPointerException
        	at org.sonar.runner.Main.delegateExecution(Main.java:114)
        	at org.sonar.runner.Main.execute(Main.java:67)
        	at org.sonar.runner.Main.main(Main.java:48)
        Caused by: java.lang.NullPointerException
        	at org.sonar.plugins.web.api.ProjectFileManager.getBasedir(ProjectFileManager.java:197)
        	at org.sonar.plugins.web.api.ProjectFileManager.resolvePath(ProjectFileManager.java:273)
        	at org.sonar.plugins.web.api.ProjectFileManager.compileSourceDirs(ProjectFileManager.java:170)
        	at org.sonar.plugins.web.api.ProjectFileManager.<init>(ProjectFileManager.java:153)
        	at org.sonar.plugins.web.WebSourceImporter.<init>(WebSourceImporter.java:56)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	[-trimmed-]
        

        Looking at ProjectFileManager ln 197, it looks like the plugin assumes that a pom.xml is available, and blows an NPE when there is only a sonar-project.properties:

          public File getBasedir() {
            return project.getPom().getBasedir();
          }
        
        Show
        Gordon McNaughton added a comment - I tried again with Web Plugin 1.1, Sonar 2.8, and Sonar Runner 1.0, but still get the issue. The stack trace has changed though. If you only have a sonar-project.properties file, and not a pom.xml, sonar-runner crashes with the following: Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: java.lang.NullPointerException at org.sonar.runner.Main.delegateExecution(Main.java:114) at org.sonar.runner.Main.execute(Main.java:67) at org.sonar.runner.Main.main(Main.java:48) Caused by: java.lang.NullPointerException at org.sonar.plugins.web.api.ProjectFileManager.getBasedir(ProjectFileManager.java:197) at org.sonar.plugins.web.api.ProjectFileManager.resolvePath(ProjectFileManager.java:273) at org.sonar.plugins.web.api.ProjectFileManager.compileSourceDirs(ProjectFileManager.java:170) at org.sonar.plugins.web.api.ProjectFileManager.<init>(ProjectFileManager.java:153) at org.sonar.plugins.web.WebSourceImporter.<init>(WebSourceImporter.java:56) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [-trimmed-] Looking at ProjectFileManager ln 197, it looks like the plugin assumes that a pom.xml is available, and blows an NPE when there is only a sonar-project.properties: public File getBasedir() { return project.getPom().getBasedir(); }
        Hide
        Matthijs Galesloot added a comment -

        There are workarounds available.

        In the properties file, please specify the sources property (do not use sonar.web.sourceDirectory).
        Another possible workaround is to use absolute paths instead of relative paths.

        Show
        Matthijs Galesloot added a comment - There are workarounds available. In the properties file, please specify the sources property (do not use sonar.web.sourceDirectory). Another possible workaround is to use absolute paths instead of relative paths.
        Hide
        Fabrice Bellingard added a comment -

        Use of sonar-project.properties for Web plugin 1.2 and Sonar 2.12+ works perfectly.

        Show
        Fabrice Bellingard added a comment - Use of sonar-project.properties for Web plugin 1.2 and Sonar 2.12+ works perfectly.
        Hide
        Freddy Mallet added a comment -

        Manually tested !

        Show
        Freddy Mallet added a comment - Manually tested !

          People

          • Assignee:
            Fabrice Bellingard
            Reporter:
            Gordon McNaughton
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: