Java: Generate pom.xml with the appropriate version number.

This commit removes pom.xml and replaces it with a trivial
tool to generate it, filling in the appropriate version of
the TensorFlow runtime.
Change: 143861686
This commit is contained in:
Asim Shankar 2017-01-07 07:14:56 -08:00 committed by TensorFlower Gardener
parent 8047c97a98
commit 18ba73bea5
3 changed files with 52 additions and 16 deletions

View File

@ -92,6 +92,20 @@ cc_binary(
deps = ["//tensorflow/java/src/main/native"],
)
genrule(
name = "pom",
outs = ["pom.xml"],
cmd = "$(location generate_pom) >$@",
output_to_bindir = 1,
tools = [":generate_pom"],
)
cc_binary(
name = "generate_pom",
srcs = ["generate_pom.cc"],
deps = ["//tensorflow/c:c_api"],
)
# System.loadLibrary() on OS X looks for ".dylib" or ".jnilib"
# and no ".so". If and when https://github.com/bazelbuild/bazel/issues/914
# is resolved, perhaps this workaround rule can be removed.

View File

@ -40,22 +40,28 @@ bazel build -c opt \
//tensorflow/java:libtensorflow-jni
```
To use the library in an external Java project, publish the library to a Maven repository. For example,
publish the library to the local Maven repository using the `mvn` tool (installed separately):
### Maven
To use the library in an external Java project, publish the library to a Maven
repository. For example, publish the library to the local Maven repository
using the `mvn` tool (installed separately):
```sh
bazel build -c opt //tensorflow/java:pom
mvn install:install-file \
-Dfile=bazel-bin/tensorflow/java/libtensorflow.jar \
-DpomFile=tensorflow/java/pom.xml
-Dfile=../../bazel-bin/tensorflow/java/libtensorflow.jar \
-DpomFile=../../bazel-bin/tensorflow/java/pom.xml
```
Refer to the library using Maven coordinates. For example, if you're using Maven then place this dependency into your `pom.xml` file:
Refer to the library using Maven coordinates. For example, if you're using
Maven then place this dependency into your `pom.xml` file (replacing
0.12.head with the version of the TensorFlow runtime you wish to use).
```xml
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>libtensorflow</artifactId>
<version>0.12.0-SNAPSHOT</version>
<version>0.12.head</version>
</dependency>
```

View File

@ -1,6 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -13,20 +11,28 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
==============================================================================*/
#include <iostream>
#include <string>
#include "tensorflow/c/c_api.h"
int main(int argc, char** argv) {
std::string tmpl(R"EOF(
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.tensorflow</groupId>
<artifactId>libtensorflow</artifactId>
<version>0.12.0-SNAPSHOT</version>
<version>{{TENSORFLOW_VERSION}}</version>
<packaging>jar</packaging>
<name>tensorflow</name>
<url>https://www.tensorflow.org</url>
<inceptionYear>2015</inceptionYear>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
@ -34,11 +40,21 @@ limitations under the License.
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/tensorflow/tensorflow.git</url>
<connection>git@github.com:tensorflow/tensorflow.git</connection>
<developerConnection>scm:git:https://github.com/tensorflow/tensorflow.git</developerConnection>
</scm>
</project>
)EOF");
const std::string var("{{TENSORFLOW_VERSION}}");
const std::string val(TF_Version());
for (size_t pos = tmpl.find(var); pos != std::string::npos;
pos = tmpl.find(var)) {
tmpl.replace(pos, var.size(), val);
}
std::cout << tmpl;
return 0;
}