001/*
002 * Copyright 2012-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure.info;
018
019import org.springframework.beans.factory.annotation.Autowired;
020import org.springframework.beans.factory.annotation.Value;
021import org.springframework.boot.context.properties.ConfigurationProperties;
022import org.springframework.core.io.ClassPathResource;
023import org.springframework.core.io.Resource;
024
025/**
026 * Configuration properties for project information.
027 *
028 * @author Stephane Nicoll
029 * @since 1.4.0
030 */
031@ConfigurationProperties(prefix = "spring.info")
032public class ProjectInfoProperties {
033
034        private final Build build = new Build();
035
036        private final Git git = new Git();
037
038        public Build getBuild() {
039                return this.build;
040        }
041
042        public Git getGit() {
043                return this.git;
044        }
045
046        /**
047         * Make sure that the "spring.git.properties" legacy key is used by default.
048         * @param defaultGitLocation the default git location to use
049         */
050        @Autowired
051        void setDefaultGitLocation(
052                        @Value("${spring.git.properties:classpath:git.properties}") Resource defaultGitLocation) {
053                getGit().setLocation(defaultGitLocation);
054        }
055
056        /**
057         * Build specific info properties.
058         */
059        public static class Build {
060
061                /**
062                 * Location of the generated build-info.properties file.
063                 */
064                private Resource location = new ClassPathResource(
065                                "META-INF/build-info.properties");
066
067                public Resource getLocation() {
068                        return this.location;
069                }
070
071                public void setLocation(Resource location) {
072                        this.location = location;
073                }
074
075        }
076
077        /**
078         * Git specific info properties.
079         */
080        public static class Git {
081
082                /**
083                 * Location of the generated git.properties file.
084                 */
085                private Resource location;
086
087                public Resource getLocation() {
088                        return this.location;
089                }
090
091                public void setLocation(Resource location) {
092                        this.location = location;
093                }
094
095        }
096
097}