Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an env.properties file in shogun2-webapp-archetype #266

Merged
merged 2 commits into from
Aug 16, 2017

Conversation

chrismayer
Copy link
Collaborator

This adds a properties file providing important project information derived from the project's pom.xml.
So the properties (name, version, etc.) can be easily used in the Java code. This is for example very useful for documenting things in an automated way.

Access could be implemented like this:

@PropertySource({ "classpath:META-INF/env.properties" })
public class MyClass {

    @Autowired
    private Environment env;

    private printEnv() {

        System.out.println("groupId " + this.env.getProperty("env.prj.groupId"));
        System.out.println("artifactId " + this.env.getProperty("env.prj.artifactId"));
        System.out.println("version " + this.env.getProperty("env.prj.version"));
        System.out.println("packaging " + this.env.getProperty("env.prj.packaging"));
        System.out.println("name " + this.env.getProperty("env.prj.name"));
        System.out.println("description " + this.env.getProperty("env.prj.description"));
        System.out.println("shogun2.version " + this.env.getProperty("env.prj.shogun2.version"));
    }
}

This adds a properties file providing important project information derived
from the project's pom.xml.
So the properties (name, version, etc.) can be easily used in the Java
code.
@chrismayer
Copy link
Collaborator Author

Anyone willing for a review? TIA!

@dnlkoch
Copy link
Member

dnlkoch commented Aug 16, 2017

This is a very useful addition! Thanks for this and please merge at will.

@chrismayer
Copy link
Collaborator Author

Thanks @dnlkoch for the review! Will merge now...

@chrismayer chrismayer merged commit f4e10c2 into terrestris:master Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants