aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-09-01 11:22:19 +0200
committerJon Bratseth <bratseth@gmail.com>2020-09-01 11:22:19 +0200
commit56ed305df446f9546a9db267a773d65d7c040d8e (patch)
tree936971d82100910a0d83412646b2ce26f193cd82 /vespa-http-client
parentd2711310822f39f4e5aa4eb4cc107e9f84719450 (diff)
Generate a Vtag class in vespa-http-client
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/pom.xml22
-rwxr-xr-xvespa-http-client/src/main/bin/versiontagger.sh24
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java6
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java7
4 files changed, 49 insertions, 10 deletions
diff --git a/vespa-http-client/pom.xml b/vespa-http-client/pom.xml
index 7b055228786..e091af1f4f1 100644
--- a/vespa-http-client/pom.xml
+++ b/vespa-http-client/pom.xml
@@ -97,9 +97,31 @@
</dependency>
</dependencies>
+
<build>
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-simplified-vtag</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>src/main/bin/versiontagger.sh</executable>
+ <arguments>
+ <argument>${project.basedir}/../dist/vtag.map</argument>
+ <argument>${project.build.directory}/generated-sources/vtag/com/yahoo/vespa/http/client/core/Vtag.java</argument>
+ </arguments>
+ <sourceRoot>${project.build.directory}/generated-sources/vtag</sourceRoot>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
diff --git a/vespa-http-client/src/main/bin/versiontagger.sh b/vespa-http-client/src/main/bin/versiontagger.sh
new file mode 100755
index 00000000000..05682c3f940
--- /dev/null
+++ b/vespa-http-client/src/main/bin/versiontagger.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+# Extracts the current version number (V_TAG_COMPONENT) from vtag.map and outputs this into a Java class.
+# This replaces vespajlib/../VersionTagger.java as this module cannot depend on that, nor the dependencies
+# of the resulting class.
+#
+# Author: bratseth
+
+source=$1
+destination=$2
+destinationDir=$(dirname $destination)
+
+mkdir -p $destinationDir
+
+versionNumber=$(cat $source | grep V_TAG_COMPONENT | awk '{print $2}' )
+
+cat > $destination <<- END
+package com.yahoo.vespa.http.client.core;
+
+public class Vtag {
+ public static final String V_TAG_COMPONENT = "$versionNumber";
+}
+END
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java
index a46b2e67fe1..bd5cf761024 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java
@@ -8,6 +8,7 @@ import com.yahoo.security.SslContextBuilder;
import com.yahoo.vespa.http.client.config.ConnectionParams;
import com.yahoo.vespa.http.client.config.Endpoint;
import com.yahoo.vespa.http.client.config.FeedParams;
+import com.yahoo.vespa.http.client.core.Vtag;
import com.yahoo.vespa.http.client.core.Document;
import com.yahoo.vespa.http.client.core.Encoder;
import com.yahoo.vespa.http.client.core.Headers;
@@ -16,7 +17,6 @@ import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
-import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.InputStreamEntity;
@@ -427,8 +427,8 @@ class ApacheGatewayConnection implements GatewayConnection {
}
clientBuilder.setMaxConnPerRoute(1);
clientBuilder.setMaxConnTotal(1);
- clientBuilder.setUserAgent(String.format("vespa-http-client (%s)", Vtag.currentVersion));
- clientBuilder.setDefaultHeaders(Collections.singletonList(new BasicHeader(Headers.CLIENT_VERSION, Vtag.currentVersion)));
+ clientBuilder.setUserAgent(String.format("vespa-http-client (%s)", Vtag.V_TAG_COMPONENT));
+ clientBuilder.setDefaultHeaders(Collections.singletonList(new BasicHeader(Headers.CLIENT_VERSION, Vtag.V_TAG_COMPONENT)));
clientBuilder.disableContentCompression();
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
requestConfigBuilder.setSocketTimeout(0);
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java
deleted file mode 100644
index f44a30208e7..00000000000
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-package com.yahoo.vespa.http.client.core.communication;
-
-class Vtag {
- static final String currentVersion = "7.1.0";
-}