Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3792

Compilation of custom rule project fails due to missing metadata files

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.15
    • Component/s: Rules
    • Labels:

      Description

      The tutorial for custom Java rules relies on annotation to provide metadata (key, name, description, priority and tags) for a user's custom implementation.
      However, RuleMetadataLoader in sonar-analyzer-commons only reads the key from the annotation and then tries to read the rest of the metadata from resource files that are not generated as part of the tutorial.

      This leads to the following error when compiling the custom rule project (where MyFirstCustomCheck is the custom rule).

      [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.3 s <<< FAILURE! - in org.sonar.samples.java.MyJavaRulesDefinitionTest
      [ERROR] org.sonar.samples.java.MyJavaRulesDefinitionTest.test  Time elapsed: 0.249 s  <<< ERROR!
      java.lang.IllegalStateException: Can't read resource: org/sonar/l10n/java/rules/java/MyFirstCustomCheck.html
      	at org.sonar.samples.java.MyJavaRulesDefinitionTest.test(MyJavaRulesDefinitionTest.java:39)
      Caused by: java.io.IOException: Resource not found in the classpath: org/sonar/l10n/java/rules/java/MyFirstCustomCheck.html
      	at org.sonar.samples.java.MyJavaRulesDefinitionTest.test(MyJavaRulesDefinitionTest.java:39)
      

      The tutorial should be updated to suggest manually creating these files to avoid any issue when compiling the custom rule project.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dorian.burihabwa Dorian Burihabwa
                Reporter:
                dorian.burihabwa Dorian Burihabwa
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: