Skip to content

Commit 4693ab8

Browse files
Merge pull request #185 from commercetools/142-Add-lib-info-in-client-headers
142: add lib info in client headers
2 parents 794339b + 0b0b35f commit 4693ab8

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

docs/RELEASE_NOTES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ are breaking changes. If there are, then a migration guide should be provided.
4646
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M5/) |
4747
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M5)
4848
49+
**Build Tools** (1)
50+
- **Commons** - Append library name and version to User-Agent headers of JVM SDK clients using the library. [#142](https://github.com/commercetools/commercetools-sync-java/issues/142)
51+
4952
**Doc Fixes** (1)
5053
- **Build Tools** - Adds Snyk vulnerabilities badge to repo README. [#188](https://github.com/commercetools/commercetools-sync-java/pull/188)
5154
-->
@@ -54,7 +57,7 @@ are breaking changes. If there are, then a migration guide should be provided.
5457
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M4/) |
5558
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M4)
5659

57-
**Bug Fixes** (1)
60+
**Hotfix** (1)
5861
- **Product Sync** - Fixes an issue with `replaceAttributesReferencesIdsWithKeys` which nullifies localized text attributes due
5962
to JSON parsing not throwing exception on parsing it to reference set. [#179](https://github.com/commercetools/commercetools-sync-java/issues/179)
6063

gradle-scripts/package.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/**
22
* Package sources to JARs
33
*/
4+
jar {
5+
manifest {
6+
attributes("Implementation-Title": rootProject.name, "Implementation-Version": rootProject.version)
7+
}
8+
}
9+
410
task sourcesJar(type: Jar, dependsOn: classes) {
511
classifier = 'sources'
612
from sourceSets.main.allSource
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.commercetools.sync.commons.utils;
2+
3+
import io.sphere.sdk.client.SolutionInfo;
4+
5+
import static java.lang.String.format;
6+
import static java.util.Optional.ofNullable;
7+
8+
public class SyncSolutionInfo extends SolutionInfo {
9+
/**
10+
* Extends {@link SolutionInfo} class of the JVM SDK to append to the User-Agent header with information of the
11+
* commercetools-sync-java library
12+
*
13+
* <p>A User-Agent header with a solution information looks like this:
14+
* {@code commercetools-jvm-sdk/1.4.1 (AHC/2.0) Java/1.8.0_92-b14 (Mac OS X; x86_64)
15+
* {@code implementationTitle}/{@code implementationVersion}
16+
* (+https://github.com/commercetools/commercetools-sync-java; +ps-dev@commercetools.com)}</p>
17+
*
18+
*/
19+
public SyncSolutionInfo() {
20+
final String libraryName = "commercetools-sync-java";
21+
final String implementationTitle = ofNullable(getClass().getPackage().getImplementationTitle())
22+
.orElse(libraryName);
23+
final String implementationVersion = ofNullable(getClass().getPackage().getImplementationVersion())
24+
.orElse("DEBUG-VERSION");
25+
setName(implementationTitle);
26+
setVersion(implementationVersion);
27+
setWebsite(format("https://github.com/commercetools/%s", libraryName));
28+
setEmergencyContact("ps-dev@commercetools.com");
29+
}
30+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.commercetools.sync.commons.utils.SyncSolutionInfo

0 commit comments

Comments
 (0)