Skip to content

Commit 5927e52

Browse files
committed
added manifest properties. fixed getting http client version
1 parent 405c1c6 commit 5927e52

File tree

5 files changed

+75
-9
lines changed

5 files changed

+75
-9
lines changed

client-v2/pom.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<packaging>jar</packaging>
1414

1515
<name>ClickHouse Client API</name>
16-
<description>New client api for ClickHouse</description>
17-
<url>https://github.com/ClickHouse/clickhouse-java/tree/main/clickhouse-client-api</url>
16+
<description>ClickHouse Client Library</description>
17+
<url>https://github.com/ClickHouse/clickhouse-java/tree/main/client-v2</url>
1818

1919
<properties>
2020
<apache.httpclient.version>5.3.1</apache.httpclient.version>
@@ -159,6 +159,22 @@
159159
<release>8</release>
160160
</configuration>
161161
</plugin>
162+
<plugin>
163+
<groupId>org.apache.maven.plugins</groupId>
164+
<artifactId>maven-assembly-plugin</artifactId>
165+
<configuration>
166+
<descriptorRefs>
167+
<descriptorRef>jar-with-dependencies</descriptorRef>
168+
</descriptorRefs>
169+
<archive>
170+
<addMavenDescriptor>false</addMavenDescriptor>
171+
<manifest>
172+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
173+
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
174+
</manifest>
175+
</archive>
176+
</configuration>
177+
</plugin>
162178
<plugin>
163179
<groupId>org.apache.maven.plugins</groupId>
164180
<artifactId>maven-shade-plugin</artifactId>

client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
import java.util.Collections;
7373
import java.util.HashMap;
7474
import java.util.Map;
75+
import java.util.Objects;
76+
import java.util.Properties;
7577
import java.util.Set;
7678
import java.util.concurrent.TimeUnit;
7779
import java.util.function.Function;
@@ -702,11 +704,30 @@ private String buildDefaultUserAgent() {
702704
userAgent.setLength(userAgent.length() - 2);
703705
userAgent.append(')');
704706

705-
userAgent.append(" ")
706-
.append(this.httpClient.getClass().getPackage().getImplementationTitle().replaceAll(" ", "-"))
707-
.append('/')
708-
.append(this.httpClient.getClass().getPackage().getImplementationVersion());
709-
707+
try {
708+
String httpClientVersion = this.httpClient.getClass().getPackage().getImplementationVersion();
709+
if (Objects.equals(this.httpClient.getClass().getPackage().getImplementationTitle(), this.getClass().getPackage().getImplementationTitle())) {
710+
// shaded jar - all packages have same implementation title
711+
httpClientVersion = "unknown";
712+
try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("client-v2-version.properties")) {
713+
Properties p = new Properties();
714+
p.load(in);
715+
716+
String tmp = p.getProperty("apache.http.client.version");
717+
if (tmp != null && !tmp.isEmpty() && !tmp.equals("${apache.httpclient.version}")) {
718+
httpClientVersion = tmp;
719+
}
720+
} catch (Exception e) {
721+
// ignore
722+
}
723+
}
724+
userAgent.append(" ")
725+
.append("Apache-HttpClient")
726+
.append('/')
727+
.append(httpClientVersion);
728+
} catch (Exception e) {
729+
LOG.info("failed to construct http client version string");
730+
}
710731
return userAgent.toString();
711732
}
712733

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
version=${revision}
2-
build.date=${build_timestamp}
2+
build.date=${build_timestamp}
3+
apache.http.client.version=${apache.httpclient.version}

examples/client-v2/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@
5959
<compiler-plugin.version>3.8.1</compiler-plugin.version>
6060

6161
<minJdk>1.8</minJdk>
62+
<clickhouse-packages.classifier>all</clickhouse-packages.classifier>
6263
</properties>
6364

6465
<dependencies>
6566
<dependency>
6667
<groupId>com.clickhouse</groupId>
6768
<artifactId>client-v2</artifactId>
6869
<version>${clickhouse-java.version}</version>
69-
<classifier>all</classifier>
70+
<classifier>${clickhouse-packages.classifier}</classifier>
7071
</dependency>
7172

7273
<!-- Recommended for JSON parsing -->

pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,33 @@
10491049
<argLine>${failsafeArgLine}</argLine>
10501050
</configuration>
10511051
</plugin>
1052+
<plugin>
1053+
<groupId>org.apache.maven.plugins</groupId>
1054+
<artifactId>maven-jar-plugin</artifactId>
1055+
<executions>
1056+
<execution>
1057+
<id>default-jar</id>
1058+
<configuration>
1059+
<archive>
1060+
<addMavenDescriptor>false</addMavenDescriptor>
1061+
<manifest>
1062+
<addDefaultEntries>true</addDefaultEntries>
1063+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
1064+
<addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
1065+
</manifest>
1066+
<manifestEntries>
1067+
<Multi-Release>true</Multi-Release>
1068+
<Implementation-URL>${project.url}</Implementation-URL>
1069+
<Implementation-Vendor>ClickHouse, Inc.</Implementation-Vendor>
1070+
<Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
1071+
<Implementation-Version><![CDATA[${project.artifactId} ${project.version} (revision: ${git.commit.id.abbrev})]]></Implementation-Version>
1072+
<SCM-Revision>${git.commit.id.full}</SCM-Revision>
1073+
</manifestEntries>
1074+
</archive>
1075+
</configuration>
1076+
</execution>
1077+
</executions>
1078+
</plugin>
10521079
</plugins>
10531080
</build>
10541081
</profile>

0 commit comments

Comments
 (0)