Пример #1
0
  /**
   * Add a token provider class from a jar manifest source. Supports either bare class names in the
   * form <tt>blah.package.ClassName</tt> or alternatively
   * <tt>blah.package.ClassName&#064;PHASE</tt> where <tt>PHASE</tt> is a case-sensitive string
   * token representing an environment phase name.
   *
   * @param provider provider class name, optionally suffixed with &#064;PHASE
   */
  static void addTokenProvider(String provider) {
    if (provider.contains("@")) {
      String[] parts = provider.split("@", 2);
      Phase phase = Phase.forName(parts[1]);
      if (phase != null) {
        MixinTweaker.logger.debug("Registering token provider class: {}", parts[0]);
        MixinEnvironment.getEnvironment(phase).registerTokenProviderClass(parts[0]);
      }
      return;
    }

    MixinEnvironment.getDefaultEnvironment().registerTokenProviderClass(provider);
  }
Пример #2
0
 /**
  * Add a config from a jar manifest source or the command line. Supports config declarations in
  * the form <tt>filename.json</tt> or alternatively <tt>filename.json&#064;PHASE</tt> where
  * <tt>PHASE</tt> is a case-sensitive string token representing an environment phase.
  *
  * @param config config resource name, does not require a leading /
  */
 static void addConfig(String config) {
   if (config.endsWith(".json")) {
     MixinTweaker.logger.debug("Registering mixin config: {}", config);
     MixinEnvironment.getDefaultEnvironment().addConfiguration(config);
   } else if (config.contains(".json@")) {
     int pos = config.indexOf(".json@");
     String phaseName = config.substring(pos + 6);
     config = config.substring(0, pos + 5);
     Phase phase = Phase.forName(phaseName);
     if (phase != null) {
       MixinTweaker.logger.debug("Registering mixin config: {}", config);
       MixinEnvironment.getEnvironment(phase).addConfiguration(config);
     }
   }
 }