title: SonarQube how to create Profile and import new rules to it
body: <p>I'm developing a plugin to SonarQube in order to import rules from a .xml file. So far this is done and they really are imported into the SonarQube instance and shown under "Rules". Although the Quality Profile is being created, all the imported rules aren't being added to it and I can't understand why.</p>
  
  <p>I don't want to add them one by one by hand; I'm looking for a way to add them directly to the created profile once they are imported from the .xml file.
  The profile is simply created with:</p>
  
  <pre><code>public class MyProfile extends ProfileDefinition {
      @Override
      public RulesProfile createProfile(ValidationMessages validation) {
          return RulesProfile.create("QP", "Java");
      }
  }
  </code></pre>
  
  <p>Here is some code of the methods that I suspect would make that happen:</p>
  
  <pre><code>public class MyRules extends RulesDefinition {
  
  public void define(Context context) {
      List&lt;RulePack&gt; rulePacks = this.rulePackParser.parse();
      parseXml(context);                                                      
      parseRulePacks(context, rulePacks);
      for (NewRepository newRepository : newRepositories.values()) {
          newRepository.done();
      }
  }
  
  private void parseXml(Context context) {
      for (Language supportedLanguage : languages.all()) {
          InputStream rulesXml = this.getClass().getResourceAsStream("/rules-TESTE.xml");
          if (rulesXml != null) {
              NewRepository repository = getRepository(context, supportedLanguage.getKey());
              xmlLoader.load(repository, new BufferedReader(new InputStreamReader(rulesXml)));
              repository.done();
          }
      }
  }
  
  private void parseRulePacks(Context context, List&lt;RulePack&gt; rulePacks) {
      for (RulePack rulePack : rulePacks) {
          for (AppScanRule rule : rulePack.getRules()) {
              String sqLanguageKey = convertToSQ(rulePack.getRuleLanguage(rule));
              if (this.languages.get(sqLanguageKey) != null &amp;&amp; isAnInterestingRule(rule)) {
                  processRule(context, rulePack, rule, sqLanguageKey);
              }
          }
      }
  }
  }
  </code></pre>
  
  <p>Thanks in advance.</p>