aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/java/maven
diff options
context:
space:
mode:
authorGravatar Asim Shankar <ashankar@google.com>2017-04-17 11:09:55 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-04-17 12:38:54 -0700
commit7737d09e9711f599ed48caa90801721c46f9b1a1 (patch)
tree18b572d3ce783733024ec6addb964068340151af /tensorflow/java/maven
parent88a6cdeb5ee79765462932a611d4d16dd715007c (diff)
Java: Publish Maven artifact for TensorFlow protocol buffers.
Change: 153371868
Diffstat (limited to 'tensorflow/java/maven')
-rw-r--r--tensorflow/java/maven/.gitignore2
-rw-r--r--tensorflow/java/maven/README.md9
-rw-r--r--tensorflow/java/maven/pom.xml1
-rw-r--r--tensorflow/java/maven/proto/pom.xml62
-rw-r--r--tensorflow/java/maven/run_inside_container.sh46
5 files changed, 117 insertions, 3 deletions
diff --git a/tensorflow/java/maven/.gitignore b/tensorflow/java/maven/.gitignore
index 50eda94643..0e11e83a0c 100644
--- a/tensorflow/java/maven/.gitignore
+++ b/tensorflow/java/maven/.gitignore
@@ -7,3 +7,5 @@ libtensorflow_jni/src
libtensorflow_jni/target
tensorflow/src
tensorflow/target
+proto/src
+proto/target
diff --git a/tensorflow/java/maven/README.md b/tensorflow/java/maven/README.md
index 19a214f42d..17bb799961 100644
--- a/tensorflow/java/maven/README.md
+++ b/tensorflow/java/maven/README.md
@@ -20,7 +20,7 @@ Hence, the process for building and uploading release artifacts is not a single
## Artifact Structure
-There are four artifacts and thus `pom.xml`s involved in this release:
+There are five artifacts and thus `pom.xml`s involved in this release:
1. `tensorflow`: The single dependency for projects requiring TensorFlow for
Java. This convenience package depends on the two below, and is the one that
@@ -34,8 +34,11 @@ There are four artifacts and thus `pom.xml`s involved in this release:
3. `libtensorflow_jni`: The native libraries required by `libtensorflow`.
Native code for all supported platforms is packaged into a single `.jar`.
-4. [`parentpom`](https://maven.apache.org/pom/index.html): Common settings
- shared between the above three.
+4. `proto`: Generated Java code for TensorFlow protocol buffers
+ (e.g., `MetaGraphDef`, `ConfigProto` etc.)
+
+5. [`parentpom`](https://maven.apache.org/pom/index.html): Common settings
+ shared by all of the above.
## Updating the release
diff --git a/tensorflow/java/maven/pom.xml b/tensorflow/java/maven/pom.xml
index cf02b17ca6..7bb191c7c7 100644
--- a/tensorflow/java/maven/pom.xml
+++ b/tensorflow/java/maven/pom.xml
@@ -30,6 +30,7 @@
<module>libtensorflow</module>
<module>libtensorflow_jni</module>
<module>tensorflow</module>
+ <module>proto</module>
</modules>
diff --git a/tensorflow/java/maven/proto/pom.xml b/tensorflow/java/maven/proto/pom.xml
new file mode 100644
index 0000000000..97feb735a1
--- /dev/null
+++ b/tensorflow/java/maven/proto/pom.xml
@@ -0,0 +1,62 @@
+<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>
+ <description>Java API for TensorFlow protocol buffers.</description>
+ <parent>
+ <groupId>org.tensorflow</groupId>
+ <artifactId>parentpom</artifactId>
+ <version>1.1.0-rc2</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <artifactId>proto</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.2.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9.1</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tensorflow/java/maven/run_inside_container.sh b/tensorflow/java/maven/run_inside_container.sh
index 684cfe1868..b5e2bfc3a6 100644
--- a/tensorflow/java/maven/run_inside_container.sh
+++ b/tensorflow/java/maven/run_inside_container.sh
@@ -23,6 +23,7 @@ IS_SNAPSHOT="false"
if [[ "${TF_VERSION}" == *"-SNAPSHOT" ]]; then
IS_SNAPSHOT="true"
fi
+PROTOC_RELEASE_URL="https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip"
set -ex
@@ -81,6 +82,50 @@ download_libtensorflow_jni() {
cd "${DIR}"
}
+# Ideally, the .jar for generated Java code for TensorFlow protocol buffer files
+# would have been produced by bazel rules. However, protocol buffer library
+# support in bazel is in flux. Once
+# https://github.com/bazelbuild/bazel/issues/2626 has been resolved, perhaps
+# TensorFlow can move to something like
+# https://bazel.build/blog/2017/02/27/protocol-buffers.html
+# for generating C++, Java and Python code for protocol buffers.
+#
+# At that point, perhaps the libtensorflow build scripts
+# (tensorflow/tools/ci_build/builds/libtensorflow.sh) can build .jars for
+# generated code and this function would not need to download protoc to generate
+# code.
+generate_java_protos() {
+ # Clean any previous attempts
+ rm -rf "${DIR}/proto/tmp"
+
+ # Download protoc
+ curl -L "${PROTOC_RELEASE_URL}" -o "/tmp/protoc.zip"
+ mkdir -p "${DIR}/proto/tmp/protoc"
+ unzip -d "${DIR}/proto/tmp/protoc" "/tmp/protoc.zip"
+ rm -f "/tmp/protoc.zip"
+
+ # Download the release archive of TensorFlow protos.
+ if [[ "${IS_SNAPSHOT}" == "true" ]]; then
+ URL="http://ci.tensorflow.org/view/Nightly/job/nightly-libtensorflow/TYPE=cpu-slave/lastSuccessfulBuild/artifact/lib_package/libtensorflow_proto.zip"
+ else
+ URL="${RELEASE_URL_PREFIX}/libtensorflow_proto-${TF_VERSION}.zip"
+ fi
+ curl -L "${URL}" -o /tmp/libtensorflow_proto.zip
+ mkdir -p "${DIR}/proto/tmp/src"
+ unzip -d "${DIR}/proto/tmp/src" "/tmp/libtensorflow_proto.zip"
+ rm -f "/tmp/libtensorflow_proto.zip"
+
+ # Generate Java code
+ mkdir -p "${DIR}/proto/src/main/java"
+ find "${DIR}/proto/tmp/src" -name "*.proto" | xargs \
+ ${DIR}/proto/tmp/protoc/bin/protoc \
+ --proto_path="${DIR}/proto/tmp/src" \
+ --java_out="${DIR}/proto/src/main/java"
+
+ # Cleanup
+ rm -rf "${DIR}/proto/tmp"
+}
+
if [ -z "${TF_VERSION}" ]
then
echo "Must set the TF_VERSION environment variable"
@@ -99,6 +144,7 @@ clean
update_version_in_pom
download_libtensorflow
download_libtensorflow_jni
+generate_java_protos
# Build the release artifacts
mvn verify
# If successfully built, try to deploy.