Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 23 additions & 7 deletions sdk/authorization/mgmt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
<artifactId>azure-resourcemanager-resources</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down Expand Up @@ -120,8 +115,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<debug>true</debug>
<optimize>true</optimize>
<compilerArguments>
Expand All @@ -130,6 +125,27 @@
</compilerArguments>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<forkCount>1</forkCount>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
<include>**/*TestCase.java</include>
</includes>
<argLine>
--patch-module com.azure.resourcemanager.resources=../../resources/mgmt/target/test-classes
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.core=com.fasterxml.jackson.databind,com.azure.core
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.core=ALL-UNNAMED,com.azure.resourcemanager.authorization
--add-reads com.azure.resourcemanager.resources=ALL-UNNAMED
Comment on lines +142 to +145
Copy link
Member Author

Choose a reason for hiding this comment

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

Black magic here...

It patches test-jar into the resources module.

</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
15 changes: 15 additions & 0 deletions sdk/authorization/mgmt/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module com.azure.resourcemanager.authorization {
requires transitive com.azure.core;
requires transitive com.azure.core.management;
requires com.azure.resourcemanager.resources;

exports com.azure.resourcemanager.authorization.models;
exports com.azure.resourcemanager.authorization;

opens com.azure.resourcemanager.authorization.models to
com.fasterxml.jackson.databind,
com.azure.core;
opens com.azure.resourcemanager.authorization.fluent.inner to
com.fasterxml.jackson.databind,
com.azure.core;
}
22 changes: 8 additions & 14 deletions sdk/management/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArgument>-Xlint:unchecked</compilerArgument>
Expand All @@ -274,7 +274,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<source>1.8</source>
<source>11</source>
<doctitle>Azure SDK for Java Reference Documentation</doctitle>
<windowtitle>Azure SDK for Java Reference Documentation</windowtitle>
<footer>Visit the &lt;a href="https://docs.microsoft.com/java/azure/"&gt;Azure for Java Developers&lt;/a&gt;site
Expand Down Expand Up @@ -353,22 +353,16 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<reuseForks>false</reuseForks>
<useSystemClassLoader>false</useSystemClassLoader>
<forkCount>1</forkCount>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
<include>**/*TestCase.java</include>
</includes>
<environmentVariables>
<test.mode>${testMode}</test.mode>
</environmentVariables>
<properties>
<configurationParameters>
junit.jupiter.execution.parallel.enabled=false
</configurationParameters>
</properties>
<argLine>
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.core=com.fasterxml.jackson.databind,com.azure.core
</argLine>
</configuration>
</plugin>

Expand Down
5 changes: 2 additions & 3 deletions sdk/resources/mgmt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -122,8 +121,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<debug>true</debug>
<optimize>true</optimize>
<compilerArguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.net.NetworkInterface;
Expand All @@ -54,20 +53,6 @@ protected AzureServiceClient(HttpPipeline httpPipeline, AzureEnvironment environ
((AzureJacksonAdapter) serializerAdapter).serializer().registerModule(DateTimeDeserializer.getModule());
}

/**
* The default User-Agent header. Override this method to override the user agent.
*
* @return the user agent string.
*/
public String userAgent() {
return String.format("Azure-SDK-For-Java/%s OS:%s MacAddressHash:%s Java:%s",
getClass().getPackage().getImplementationVersion(),
OS,
MAC_ADDRESS_HASH,
JAVA_VERSION);
}

private static final String MAC_ADDRESS_HASH;
private static final String OS;
private static final String OS_NAME;
private static final String OS_VERSION;
Expand All @@ -78,22 +63,6 @@ public String userAgent() {
OS_NAME = System.getProperty("os.name");
OS_VERSION = System.getProperty("os.version");
OS = OS_NAME + "/" + OS_VERSION;
String macAddress = "Unknown";
try {
Enumeration<NetworkInterface> networks = NetworkInterface.getNetworkInterfaces();
while (networks.hasMoreElements()) {
NetworkInterface network = networks.nextElement();
byte[] mac = network.getHardwareAddress();

if (mac != null) {
macAddress = getSha256(mac);
break;
}
}
} catch (Throwable t) {
// It's okay ignore mac address hash telemetry
}
MAC_ADDRESS_HASH = macAddress;
String version = System.getProperty("java.version");
JAVA_VERSION = version != null ? version : "Unknown";
}
Expand Down Expand Up @@ -165,17 +134,6 @@ private Mono<Response<Flux<ByteBuffer>>> activationOperation(Mono<? extends Resp
return lroInit.flatMap(fluxSimpleResponse -> Mono.just(fluxSimpleResponse));
}

private static String getSha256(byte[] bytes) {
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getInstance("SHA-256");
return new HexBinaryAdapter().marshal(messageDigest.digest(bytes));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return "Unknown";
}

/**
* Gets the final result, or an error, based on last async poll response.
*
Expand Down
28 changes: 28 additions & 0 deletions sdk/resources/mgmt/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module com.azure.resourcemanager.resources {
requires transitive com.azure.core;
requires transitive com.azure.core.management;
requires com.github.spotbugs.annotations;

exports com.azure.resourcemanager.resources.fluentcore.collection;
exports com.azure.resourcemanager.resources.fluentcore.arm.collection;
exports com.azure.resourcemanager.resources.fluentcore.arm.models;
exports com.azure.resourcemanager.resources.fluentcore.model;
exports com.azure.resourcemanager;
exports com.azure.resourcemanager.resources.fluentcore.model.implementation;
exports com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation;
exports com.azure.resourcemanager.resources.models;
exports com.azure.resourcemanager.resources.fluentcore.utils;
exports com.azure.resourcemanager.resources.fluentcore.profile;
exports com.azure.resourcemanager.resources.fluentcore.arm;
exports com.azure.resourcemanager.resources.fluentcore.arm.implementation;
exports com.azure.resourcemanager.resources.fluentcore.dag;
exports com.azure.resourcemanager.resources;
exports com.azure.resourcemanager.resources.fluent.inner;

opens com.azure.resourcemanager.resources.models to
com.fasterxml.jackson.databind,
com.azure.core;
opens com.azure.resourcemanager.resources.fluent.inner to
com.fasterxml.jackson.databind,
com.azure.core;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package com.azure.resourcemanager.resources.core;

import com.azure.core.credential.TokenCredential;
import com.azure.core.implementation.TypeUtil;
Copy link
Member Author

Choose a reason for hiding this comment

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

@ChenTanyi

Please try find time to remove dependency on implementation package.

import com.azure.core.management.AzureEnvironment;
import com.azure.core.management.serializer.AzureJacksonAdapter;
import com.azure.core.util.logging.ClientLogger;
Expand All @@ -21,7 +20,6 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
Expand Down Expand Up @@ -59,10 +57,10 @@ static AuthFile parse(File file) throws IOException {
AuthFile authFile;
if (isJsonBased(content)) {
authFile = ADAPTER.deserialize(content, AuthFile.class, SerializerEncoding.JSON);
Map<String, String> endpoints = ADAPTER.deserialize(content,
TypeUtil.createParameterizedType(Map.class, String.class, String.class),
SerializerEncoding.JSON);
authFile.environment.endpoints().putAll(endpoints);
// Map<String, String> endpoints = ADAPTER.deserialize(content,
// TypeUtil.createParameterizedType(Map.class, String.class, String.class),
// SerializerEncoding.JSON);
// authFile.environment.endpoints().putAll(endpoints);
} else {
// Set defaults
Properties authSettings = new Properties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
import com.azure.core.implementation.http.BufferedHttpResponse;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -77,7 +76,7 @@ public Mono<String> getBodyAsString(Charset charset) {
}

@Override
public BufferedHttpResponse buffer() {
return new BufferedHttpResponse(this);
public HttpResponse buffer() {
return this;
}
}