Пример #1
0
 static {
   // Output directories should be specified (recommended by Apple -
   // http://developer.apple.com/devcenter/download.action?path=/wwdc_2012/wwdc_2012_session_pdfs/session_404__building_from_the_command_line_with_xcode.pdf)
   for (ManagedSetting setting : ManagedSetting.values()) {
     if (setting.isRequired()) {
       REQUIRED.put(setting.name(), setting.getDefaultValue());
     }
   }
 }
Пример #2
0
    static ManagedSetting forName(String name) {

      for (ManagedSetting setting : values()) {
        if (setting.name().equals(name)) {
          return setting;
        }
      }

      return null;
    }
Пример #3
0
  /**
   * @param userSettings to be validated.
   * @return the passed in userSettings if validation passed without exception
   * @throws IllegalArgumentException if the userSettings contain a key of an XCode setting that is
   *     managed by the plugin.
   */
  private static final Map<String, String> validateUserSettings(Map<String, String> userSettings) {

    for (String key : userSettings.keySet()) {
      if (ManagedSetting.forName(key.trim()) != null) {
        throw new IllegalArgumentException(
            "Setting '"
                + key
                + "' contained in user settings. This settings is managed by the plugin and must not be provided from outside.");
      }
    }
    return userSettings;
  }
Пример #4
0
  Settings(Map<String, String> userSettings, Map<String, String> managedSettings) {

    if (userSettings == null) {
      this.userSettings = Collections.emptyMap();
    } else {
      this.userSettings = Collections.unmodifiableMap(new HashMap<String, String>(userSettings));
    }

    validateUserSettings(this.userSettings);

    if (managedSettings == null) {
      this.managedSettings = Collections.unmodifiableMap(new HashMap<String, String>(REQUIRED));
    } else {

      Map<String, String> _managedSettings = new HashMap<String, String>();

      for (Map.Entry<String, String> e : managedSettings.entrySet()) {

        if (e.getKey() == null || e.getKey().trim().isEmpty())
          throw new IllegalArgumentException(
              "Empty key found in settings. Value was: '" + e.getValue() + "'.");

        if (ManagedSetting.forName(e.getKey().trim()) == null)
          throw new IllegalArgumentException(
              "Setting with key '"
                  + e.getKey()
                  + "' and value '"
                  + e.getValue()
                  + "' was provided. This setting is managed by the plugin"
                  + "and must not be provided as managed setting.");

        if (e.getValue() == null) {

          if (e.getKey().equals(ManagedSetting.CODE_SIGN_IDENTITY.name())) {
            throw new IllegalArgumentException(
                "CodesignIdentity was empty: '"
                    + e.getValue()
                    + "'. If you want to use the code"
                    + " sign identity defined in the xCode project configuration just do"
                    + " not provide the 'codeSignIdentity' in your Maven settings.");
          }

          throw new IllegalArgumentException("No value provided for key '" + e.getKey() + "'.");
        }

        _managedSettings.put(e.getKey(), e.getValue());
      }
      _managedSettings.putAll(REQUIRED);
      this.managedSettings =
          Collections.unmodifiableMap(new HashMap<String, String>(_managedSettings));
    }
  }