This returns the CLIENT app MDW version (as opposed to the CLI version
returned by run());
TODO: Read mdw version from plugin.xml if present, and compare
with gradle.properties.
TODO: Support mdw version in pom.xml as alternative to gradle.properties.
163001
public String getMdwVersion(File projectDir) throws IOException {
        File gradleProps = new File(projectDir + "/gradle.properties");
        if (!gradleProps.exists())
            throw new IOException("Missing: " + gradleProps.getAbsolutePath());
        Properties props = new Properties();
        props.load(new FileInputStream(gradleProps));
        return props.getProperty("mdwVersion");
    }
109849
public static String getArtifactoryPluginVersion() {
        String pluginsSortName = "artifactory";
        //Validates Jenkins existence because in some jobs the Jenkins instance is unreachable
        if (Jenkins.getInstance() != null
                && Jenkins.getInstance().getPlugin(pluginsSortName) != null
                && Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper() != null) {
            return Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper().getVersion();
        }
        return "";
    }
144115
private static String getVersionFromPom(final Path path) {
		Path folder = path;
		Path file;

		while (true) {
			file = folder.resolve("pom.xml");
			if (Files.exists(file)) {
				break;
			}

			folder = folder.getParent();
			if (folder == null) {
				Logger.error("pom.xml is missing for \"{}\"", path);
				return null;
			}
		}

		String content;
		try {
			content = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
		} catch (IOException ex) {
			Logger.error(ex, "Failed reading \"{}\"", path);
			return null;
		}

		Matcher matcher = POM_VERSION.matcher(content);
		if (matcher.find()) {
			return matcher.group(1);
		} else {
			Logger.error("POM \"{}\" does not contain a version", file);
			return null;
		}
	}
388911
public static String getVersion() {
        String version = Default.VERSION_UNKNOW.toString();
        try (InputStream inputStream = Resources.getResource(Default.VERSION_PROPERTIES.toString()).openStream()) {
            final Properties properties = new Properties();
            properties.load(inputStream);
            version = String.valueOf(properties.get("version"));
        } catch (final IOException e) {
            LOG.error("Failed to get application version", e);
        }

        return version;
    }
28648
public static String getBuildVersion(){
    return VersionInfo.getVersion() + 
    " from " + VersionInfo.getRevision() +
    " by " + VersionInfo.getUser() + 
    " on " + VersionInfo.getDate();
  }
1318978
public static Version version() {
    final IntByReference major = new IntByReference();
    final IntByReference minor = new IntByReference();
    final IntByReference patch = new IntByReference();

    LIB.mdb_version(major, minor, patch);

    return new Version(major.intValue(), minor.intValue(), patch.
                       intValue());
  }
1057354
public static String getVersion() {
        String version = null;

        // try to load from maven properties first
        try {
            Properties p = new Properties();
            InputStream is = VersionHelper.class.getResourceAsStream("/META-INF/maven/io.redlink/redlink-sdk-java/pom.properties");
            if (is != null) {
                p.load(is);
                version = p.getProperty("version", "");
            }
        } catch (Exception e) {
            // ignore
        }

        // fallback to using Java API
        if (version == null) {
            Package aPackage = VersionHelper.class.getPackage();
            if (aPackage != null) {
                version = aPackage.getImplementationVersion();
                if (version == null) {
                    version = aPackage.getSpecificationVersion();
                }
            }
        }

        // fallback to read pom.xml on testing
        if (version == null) {
            final MavenXpp3Reader reader = new MavenXpp3Reader();
            try {
                Model model = reader.read(new FileReader(new File("pom.xml")));
                version = model.getVersion();
            } catch (IOException | XmlPullParserException e) {
                // ignore
            }
        }

        return version;
    }
376256
public static String getVersion() {

        String FATHOM_PROPERTIES = "fathom/version.properties";
        String version = null;

        URL url = ClassUtil.getResource(FATHOM_PROPERTIES);
        Preconditions.checkNotNull(url, "Failed to find " + FATHOM_PROPERTIES);

        try (InputStream stream = url.openStream()) {
            Properties prop = new Properties();
            prop.load(stream);

            version = prop.getProperty("version");

        } catch (IOException e) {
            LoggerFactory.getLogger(Constants.class).error("Failed to read '{}'", FATHOM_PROPERTIES, e);
        }

        Preconditions.checkNotNull(version, "The Fathom version is null!");

        return version;
    }
405556
public static String getVersion() {
        if (version != null)
            return version;
        try (InputStream stream = CDK.class.getResourceAsStream(RESOURCE_LOCATION)) {
            if (stream == null) {
                // load from JAR (as packaged with maven)
                version = CDK.class.getPackage().getImplementationVersion();
            }
            Properties props = new Properties();
            props.load(stream);
            version = props.getProperty("version");
            return version;
        } catch (IOException exception) {
            // there is no back up
            logger.error("Error while loading the build.props file: ", exception.getMessage());
            logger.debug(exception);
        }
        return null;
    }
606952
public static String getApplicationVersionFromJar(Class<?> _class, String _default) {
        try {
            Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF");
            while (resources.hasMoreElements()) {

                Manifest manifest = new Manifest(resources.nextElement().openStream());
                Attributes attribs = manifest.getMainAttributes();
                String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
                if (ver == null) {
                	return _default;
                }

                String rev = attribs.getValue("Implementation-Revision");
                if (rev != null) {
                    ver += "-r" + rev;
                }
                return ver;

            }
        } catch (IOException _ex) {
        }

        return _default;
    }
889714
public String getVersion(String configString) {
    if (configString == null
        || configString.trim().isEmpty()
        || configString.equals(APPENGINE_CONFIG)) {
      throw new GradleException(VERSION_ERROR);
    }
    if (configString.equals(GCLOUD_CONFIG)) {
      // can be null to allow gcloud to generate this
      return null;
    }
    return configString;
  }
511920
def get_build_tool_version(self):
    
    with open('%s/%s/build.gradle' % (self.path, self.src_folder)) as f:
      for line in f.readlines():
        if 'buildToolsVersion' in line:
          matches = re.findall(r'buildToolsVersion \"(.+?)\"', line)
          if len(matches) == 1:
            return matches[0]
    return config.build_tool_version
650150
@Override
	public Mono<VersionInfo> version() {
		return credHubOperations.doWithWebClient(webClient -> webClient
				.get()
				.uri(VERSION_URL_PATH)
				.retrieve()
				.onStatus(HttpStatus::isError, ExceptionUtils::buildError)
				.bodyToMono(VersionInfo.class));
	}
892656
public static Optional<String> loadVersionFromPom() {
    try (InputStream stream = ErrorProneVersion.class.getResourceAsStream(PROPERTIES_RESOURCE)) {
      if (stream == null) {
        return Optional.absent();
      }
      Properties mavenProperties = new Properties();
      mavenProperties.load(stream);
      return Optional.of(mavenProperties.getProperty("version"));
    } catch (IOException expected) {
      return Optional.absent();
    }
  }
178492
public static @Nonnull String getLastExecVersion() {
        File lastExecVersionFile = getLastExecVersionFile();
        if (lastExecVersionFile.exists()) {
            try {
                String version = FileUtils.readFileToString(lastExecVersionFile);
                // JENKINS-37438 blank will force the setup
                // wizard regardless of current state of the system
                if (StringUtils.isBlank(version)) {
                    return FORCE_NEW_INSTALL_VERSION.toString();
                }
                return version;
            } catch (IOException e) {
                LOGGER.log(SEVERE, "Unexpected Error. Unable to read " + lastExecVersionFile.getAbsolutePath(), e);
                LOGGER.log(WARNING, "Unable to determine the last running version (see error above). Treating this as a restart. No plugins will be updated.");
                return getCurrentExecVersion();
            }
        } else {
            // Backward compatibility. Use the last version stored in the top level config.xml.
            // Going to read the value directly from the config.xml file Vs hoping that the
            // Jenkins startup sequence has moved far enough along that it has loaded the
            // global config. It can't load the global config until well into the startup
            // sequence because the unmarshal requires numerous objects to be created e.g.
            // it requires the Plugin Manager. It happens too late and it's too risky to
            // change how it currently works.
            File configFile = getConfigFile();
            if (configFile.exists()) {
                try {
                    String lastVersion = XMLUtils.getValue("/hudson/version", configFile);
                    if (lastVersion.length() > 0) {
                        LOGGER.log(Level.FINE, "discovered serialized lastVersion {0}", lastVersion);
                        return lastVersion;
                    }
                } catch (Exception e) {
                    LOGGER.log(SEVERE, "Unexpected error reading global config.xml", e);
                }
            }
            return NEW_INSTALL_VERSION.toString();
        }
    }
371691
@GET
  @Path("/check")
  @Produces(APPLICATION_JSON)
  @Timed
  @ExceptionMetered
  public VersionCheckResponse versionCheck(
      @QueryParam("client") @DefaultValue("") final String client) {
    final PomVersion serverVersion = PomVersion.parse(Version.POM_VERSION);
    final VersionCompatibility.Status status;

    if (isNullOrEmpty(client)) {
      return new VersionCheckResponse(VersionCompatibility.Status.MISSING,
          serverVersion, Version.RECOMMENDED_VERSION);
    }

    final PomVersion clientVersion = PomVersion.parse(client);
    status = VersionCompatibility.getStatus(serverVersion, clientVersion);
    return new VersionCheckResponse(status, serverVersion, Version.RECOMMENDED_VERSION);
  }
1173587
public static String getVersion()
    {

        URL versionFile = SnappyLoader.class
                .getResource("/META-INF/maven/org.xerial.snappy/snappy-java/pom.properties");
        if (versionFile == null) {
            versionFile = SnappyLoader.class.getResource("/org/xerial/snappy/VERSION");
        }

        String version = "unknown";
        try {
            if (versionFile != null) {
                Properties versionData = new Properties();
                versionData.load(versionFile.openStream());
                version = versionData.getProperty("version", version);
                if (version.equals("unknown")) {
                    version = versionData.getProperty("SNAPPY_VERSION", version);
                }
                version = version.trim().replaceAll("[^0-9M\\.]", "");
            }
        }
        catch (IOException e) {
            System.err.println(e);
        }
        return version;
    }