protected String getNewLiferayProfilesPluginVersion(
      String[] activeProfiles,
      List<NewLiferayProfile> newLiferayProfiles,
      String archetypeVersion) {
    org.osgi.framework.Version minVersion =
        new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

    try {
      final List<Profile> profiles = MavenPlugin.getMaven().getSettings().getProfiles();

      org.osgi.framework.Version minNewVersion =
          new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

      org.osgi.framework.Version minExistedVersion =
          new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

      for (final String activeProfile : activeProfiles) {
        for (final NewLiferayProfile newProfile : newLiferayProfiles) {
          if (activeProfile.equals(newProfile.getId().content())) {
            final String liferayVersion = newProfile.getLiferayVersion().content();

            final org.osgi.framework.Version shortLiferayVersion =
                new org.osgi.framework.Version(liferayVersion.substring(0, 3));

            final org.osgi.framework.Version shortPluginVersion =
                new org.osgi.framework.Version(archetypeVersion.substring(0, 3));

            minNewVersion =
                shortLiferayVersion.compareTo(shortPluginVersion) < 0
                    ? shortLiferayVersion
                    : shortPluginVersion;
          }
        }

        minVersion = minVersion.compareTo(minNewVersion) < 0 ? minVersion : minNewVersion;

        for (final Profile existProfile : profiles) {
          if (activeProfile.equals(existProfile.getId())) {
            final Properties properties = existProfile.getProperties();
            final String liferayVersion = properties.getProperty("liferay.version");
            final String pluginVersion = properties.getProperty("liferay.maven.plugin.version");

            if (pluginVersion != null && liferayVersion != null) {
              final org.osgi.framework.Version shortLiferayVersion =
                  new org.osgi.framework.Version(liferayVersion.substring(0, 3));

              final org.osgi.framework.Version shortPluginVersion =
                  new org.osgi.framework.Version(pluginVersion.substring(0, 3));

              minExistedVersion =
                  shortLiferayVersion.compareTo(shortPluginVersion) < 0
                      ? shortLiferayVersion
                      : shortPluginVersion;
            }
          }
        }

        minVersion = minVersion.compareTo(minExistedVersion) < 0 ? minVersion : minExistedVersion;
      }
    } catch (Exception e) {
    }

    return minVersion.toString();
  }