[
https://issues.apache.org/jira/browse/MAHOUT-875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13156354#comment-13156354
]
Ted Dunning commented on MAHOUT-875:
------------------------------------
{quote}
{{driver.classes.props}} contains now the key {{org.apache.mahout.version}}. It
is set to the value of {{project.version}}. To replace the property by its
value, I use the filterchain feature of Ant.
{quote}
It would be better to not depend on ant and use the property replacement
capabilities of Maven. In particular, resources already get this treatment by
default so you can put references to the properties you care about in a
resource and simply read that resource when you want the version info.
In addition, the version of Mahout is to be found in the META-INF directory in
the jar. This allows this code to get the desired version. Resources can also
be used.
Here is sample code:
{code}
public class Version {
public static String version() {
return Version.class.getPackage().getImplementationVersion();
}
public static String versionFromResource() throws IOException {
return Resources.toString(Resources.getResource("version"), Charsets.UTF_8);
}
}
{code}
Unfortunately, the standard method based on Package.getImplementationVersion
will not work with our current job jar because of some non-standardness in the
build process. It does work on the mahout-core jar itself. Also, it doesn't
work in debugging since it depends on META-INF appearing in the right jar.
The resources approach will work regardless of how the code is packaged. To
interpolate variables into a resource, the following needs to be added to the
pom:
{code}
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
{code}
This should be added to the <build> element.
The following needs to be put into a file in core/src/main/resources/version
{code}
${project.version}
{code}
See also
http://docs.oracle.com/javase/tutorial/deployment/jar/packageman.html
http://docs.oracle.com/javase/7/docs/technotes/guides/versioning/spec/versioning2.html#wp89936
http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
> Allow to obtain Mahout version information through the Java API
> ---------------------------------------------------------------
>
> Key: MAHOUT-875
> URL: https://issues.apache.org/jira/browse/MAHOUT-875
> Project: Mahout
> Issue Type: Improvement
> Affects Versions: 0.6
> Reporter: Oliver B. Fischer
> Priority: Trivial
> Fix For: 0.6
>
> Attachments: MAHOUT-875.patch
>
>
> It would be nice to be able to obtain the used Mahout version through the
> Java API. This enables users to output the version information for debugging
> purposes or simple to document which Mahout version is used.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira