Provide Java compiler with bootstrap classes for Java7
when compiling Java7-compatible sources.
This commit is contained in:
parent
4c8a790c3b
commit
212d4d3c71
|
@ -37,7 +37,7 @@ public final class AwsClientInstrumentation extends AbstractAwsClientInstrumenta
|
|||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static void methodEnter(@Advice.This final SdkClientBuilder thiz) {
|
||||
thiz.overrideConfiguration(TracingExecutionInterceptor.getOverrideConfigurationConsumer());
|
||||
TracingExecutionInterceptor.overrideConfiguration(thiz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public final class AwsHttpClientInstrumentation extends AbstractAwsClientInstrum
|
|||
* this instrumentation when TracingExecutionInterceptor would not work.
|
||||
*/
|
||||
public static void muzzleCheck() {
|
||||
TracingExecutionInterceptor.getOverrideConfigurationConsumer();
|
||||
TracingExecutionInterceptor.muzzleCheck();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.opentracing.util.GlobalTracer;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import software.amazon.awssdk.core.client.builder.SdkClientBuilder;
|
||||
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
|
||||
import software.amazon.awssdk.core.interceptor.Context;
|
||||
import software.amazon.awssdk.core.interceptor.ExecutionAttribute;
|
||||
|
@ -84,8 +85,16 @@ public class TracingExecutionInterceptor implements ExecutionInterceptor {
|
|||
}
|
||||
}
|
||||
|
||||
public static Consumer<ClientOverrideConfiguration.Builder> getOverrideConfigurationConsumer() {
|
||||
return OVERRIDE_CONFIGURATION_CONSUMER;
|
||||
/**
|
||||
* We keep this method here because it references Java8 classes and we would like to avoid
|
||||
* compiling this for instrumentation code that should load into Java7.
|
||||
*/
|
||||
public static void overrideConfiguration(final SdkClientBuilder client) {
|
||||
client.overrideConfiguration(OVERRIDE_CONFIGURATION_CONSUMER);
|
||||
}
|
||||
|
||||
public static void muzzleCheck() {
|
||||
// Noop
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,23 @@ if (applyCodeCoverage) {
|
|||
sourceCompatibility = 1.7
|
||||
targetCompatibility = 1.7
|
||||
|
||||
[JavaCompile, ScalaCompile].each { type ->
|
||||
tasks.withType(type) {
|
||||
doFirst {
|
||||
// We do this specifically for Java7 bytecode generation because we would like to be able to compile
|
||||
// with Java8+ compiler. This likely would require some modifications when we switch to java11 compiler.
|
||||
// Using proper Java7 bootstrap and extentions allows to be sure our code will run on real Java7.
|
||||
if (JavaVersion.toVersion(sourceCompatibility) == JavaVersion.VERSION_1_7
|
||||
&& JavaVersion.current() != JavaVersion.VERSION_1_7
|
||||
&& System.env.JAVA_7_HOME != null) {
|
||||
options.fork = true
|
||||
options.bootstrapClasspath = fileTree(include: ['*.jar'], dir: "${System.env.JAVA_7_HOME}/jre/lib/")
|
||||
options.extensionDirs = "${System.env.JAVA_7_HOME}/jre/lib/ext/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "io.franzbecker.gradle-lombok"
|
||||
|
||||
lombok { // optional: values below are the defaults
|
||||
|
|
Loading…
Reference in New Issue