Skip to content

Instantly share code, notes, and snippets.

@DaddyMoe
Created March 24, 2017 11:54
Show Gist options
  • Save DaddyMoe/8d7e6ee735cb1dda75f9be8204decce5 to your computer and use it in GitHub Desktop.
Save DaddyMoe/8d7e6ee735cb1dda75f9be8204decce5 to your computer and use it in GitHub Desktop.
Dynamically set API version in code from pom.xml. Great on CI where one is not manually tempering with versions.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin
<!-- Then in Code `getClass().getPackage().getImplementationVersion()` -->
<!-- For Example to set API on Swagger do:
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.version(getClass().getPackage().getImplementationVersion())
.build();
}
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment