简体   繁体   中英

How to display SVN revision stored in war manifest.mf file on Tapestry5 page?

I'm using buildnumber-maven-plugin and maven-war-plugin to generate and put SVN revision into manifest.mf file in my WAR file as an entry.

<Implementation-Build>${buildNumber}</Implementation-Build>

So far, so good.

I would like to display it on Tapestry page (5.3.6 version). How would I do that? What is the best approach?

<html t:type="layout" title="" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
    <div>
        <h4>Version:</h4>
             ${project.version}
        <h4>Revision:</h4>
            ${buildNumber}
    </div>
</html>

Add in your MANIFEST.MF

Implementation-Build

Implementation-Version: 11111

In your AppModule.java

public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration) {
    .......
    String version = "0";
    if (null != AppModule.class.getPackage()) {
        version = AppModule.class.getPackage().getImplementationVersion();
    }

    configuration.add(SymbolConstants.APPLICATION_VERSION, version);
    .......
}

Add property in your page class

@Inject
@Symbol(SymbolConstants.APPLICATION_VERSION)
@Property
protected String buildNumber;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM