Вы можете добавить pom в папку META-INF, как предложено выше.Вы также можете использовать файл pom.properties, который Jar и связанные плагины архивов Maven помещают в META-INF по умолчанию.В любом случае вы можете получить к нему доступ как к ресурсу, если jar находится в пути к классам.Единственный пример, который у меня есть, написан на Groovy:
def static String getMavenVersion(Class mainClass) {
//
// If this doesn't work, the likely reason is that we're running in development, so start with a
// reasonable default
//
def String result = "Lastest Development"
//
// Get our package - one up in the tree is the path to the properties file we want.
//
def String packagePath = mainClass.package.name
def int index = packagePath.lastIndexOf(".")
def String groupId = packagePath.substring(0, index)
def String artifact = packagePath.substring(index + 1)
//
// Get the version from the property file
//
Protect.resource
{
InputStream input = MiscUtils.class.getResourceAsStream("/META-INF/maven/${groupId}/${artifact}/pom.properties")
input
}
{ InputStream input ->
if (input != null) {
def Properties mavenProps = new Properties()
mavenProps.load(input)
result = mavenProps.getAt("version")
}
}
result
}