Java Code Examples for org.springframework.boot.info.BuildProperties#getVersion()

The following examples show how to use org.springframework.boot.info.BuildProperties#getVersion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrefixedKeyGenerator.java    From jhipster with Apache License 2.0 6 votes vote down vote up
private String generatePrefix(GitProperties gitProperties, BuildProperties buildProperties) {

        String shortCommitId = null;
        if (Objects.nonNull(gitProperties)) {
            shortCommitId = gitProperties.getShortCommitId();
        }

        Instant time = null;
        String version = null;
        if (Objects.nonNull(buildProperties)) {
            time = buildProperties.getTime();
            version = buildProperties.getVersion();
        }
        Object p = ObjectUtils.firstNonNull(shortCommitId, time, version, RandomStringUtils.randomAlphanumeric(12));

        if (p instanceof Instant) {
            return DateTimeFormatter.ISO_INSTANT.format((Instant) p);
        }
        return p.toString();
    }
 
Example 2
Source File: BuildInfoMapper.java    From holdmail with Apache License 2.0 2 votes vote down vote up
public BuildInfo fromProperties(BuildProperties properties) {

        return new BuildInfo(properties.getVersion(), properties.getTime());
    }