Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgmt, update user-agent #13085

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
read version from properties prepared by maven
  • Loading branch information
weidongxu-microsoft committed Jul 14, 2020
commit 0fd94a5426981ea5a61dbb3e8fb4b106c3ffa210
8 changes: 8 additions & 0 deletions sdk/resources/mgmt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<legal>
<![CDATA[[INFO] Any downloads listed may be third party software. Microsoft grants you no rights for third party software.]]></legal>
<version>${project.version}</version>
</properties>

<developers>
Expand Down Expand Up @@ -88,6 +89,13 @@
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
Comment on lines +91 to +96
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now doing this for version @yungezz


<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.azure.core.management.polling.PollResult;
import com.azure.core.management.serializer.AzureJacksonAdapter;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.polling.AsyncPollResponse;
import com.azure.core.util.polling.LongRunningOperationStatus;
Expand Down Expand Up @@ -45,15 +46,17 @@ public abstract class AzureServiceClient {

private final ClientLogger logger = new ClientLogger(getClass());

private static final Map<String, String> PROPERTIES =
CoreUtils.getProperties("azure.properties");

protected AzureServiceClient(HttpPipeline httpPipeline, AzureEnvironment environment) {
((AzureJacksonAdapter) serializerAdapter).serializer().registerModule(DateTimeDeserializer.getModule());
}

private static final String SDK_VERSION = "2.0.0-SNAPSHOT";

private final SerializerAdapter serializerAdapter = new AzureJacksonAdapter();

private String sdkName;
private static String sdkVersion;

/**
* Gets serializer adapter for JSON serialization/de-serialization.
Expand All @@ -73,8 +76,11 @@ public Context getContext() {
if (sdkName == null) {
sdkName = this.getClass().getPackage().getName();
}
if (sdkVersion == null) {
sdkVersion = PROPERTIES.getOrDefault("version", "UnknownVersion");
}
return new Context("Sdk-Name", sdkName)
.addData("Sdk-Version", SDK_VERSION);
.addData("Sdk-Version", sdkVersion);
}

/**
Expand Down
1 change: 1 addition & 0 deletions sdk/resources/mgmt/src/main/resources/azure.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${project.version}