본문 바로가기
IT/JAVA

How can I get jar file's Implementation version

by 최고영회 2023. 2. 20.
728x90
반응형
SMALL

If application support rest api 

pom.xml

<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>
 

api controller

return new ResponseEntity<>(getClass().getPackage().getImplementationVersion(), HttpStatus.OK);
 

 

If not support rest api 

unzip and read Implementation-Version from MANIFEST.MF file

#!/bin/sh

version="$(unzip -p yhkim.jar META-INF/MANIFEST.MF | grep Implementation-Version | cut -d':' -f 2)"
version=`echo $version | sed 's/ *$//g'`
echo "$version"
~
 
 

 

 

728x90
반응형
LIST