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:
parent
8047c97a98
commit
18ba73bea5
@ -92,6 +92,20 @@ cc_binary(
|
|||||||
deps = ["//tensorflow/java/src/main/native"],
|
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"
|
# System.loadLibrary() on OS X looks for ".dylib" or ".jnilib"
|
||||||
# and no ".so". If and when https://github.com/bazelbuild/bazel/issues/914
|
# and no ".so". If and when https://github.com/bazelbuild/bazel/issues/914
|
||||||
# is resolved, perhaps this workaround rule can be removed.
|
# is resolved, perhaps this workaround rule can be removed.
|
||||||
|
@ -40,22 +40,28 @@ bazel build -c opt \
|
|||||||
//tensorflow/java:libtensorflow-jni
|
//tensorflow/java:libtensorflow-jni
|
||||||
```
|
```
|
||||||
|
|
||||||
To use the library in an external Java project, publish the library to a Maven repository. For example,
|
### Maven
|
||||||
publish the library to the local Maven repository using the `mvn` tool (installed separately):
|
|
||||||
|
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
|
```sh
|
||||||
|
bazel build -c opt //tensorflow/java:pom
|
||||||
mvn install:install-file \
|
mvn install:install-file \
|
||||||
-Dfile=bazel-bin/tensorflow/java/libtensorflow.jar \
|
-Dfile=../../bazel-bin/tensorflow/java/libtensorflow.jar \
|
||||||
-DpomFile=tensorflow/java/pom.xml
|
-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
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.tensorflow</groupId>
|
<groupId>org.tensorflow</groupId>
|
||||||
<artifactId>libtensorflow</artifactId>
|
<artifactId>libtensorflow</artifactId>
|
||||||
<version>0.12.0-SNAPSHOT</version>
|
<version>0.12.head</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -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");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -13,14 +11,22 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
|||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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"
|
<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">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.tensorflow</groupId>
|
<groupId>org.tensorflow</groupId>
|
||||||
<artifactId>libtensorflow</artifactId>
|
<artifactId>libtensorflow</artifactId>
|
||||||
<version>0.12.0-SNAPSHOT</version>
|
<version>{{TENSORFLOW_VERSION}}</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>tensorflow</name>
|
<name>tensorflow</name>
|
||||||
@ -40,5 +46,15 @@ limitations under the License.
|
|||||||
<connection>git@github.com:tensorflow/tensorflow.git</connection>
|
<connection>git@github.com:tensorflow/tensorflow.git</connection>
|
||||||
<developerConnection>scm:git:https://github.com/tensorflow/tensorflow.git</developerConnection>
|
<developerConnection>scm:git:https://github.com/tensorflow/tensorflow.git</developerConnection>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
</project>
|
</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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user