@@ -199,33 +199,43 @@ private static void configureNativeLibraryPath(Project project) {
199199
200200 private static void configureEntitlements (Project project ) {
201201 Configuration agentJarConfig = project .getConfigurations ().create ("entitlementAgentJar" );
202- agentJarConfig .defaultDependencies (deps -> {
203- deps .add (project .getDependencies ().project (Map .of ("path" , ":libs:entitlement:agent" , "configuration" , "default" )));
204- });
202+ Project agent = project .findProject (":libs:entitlement:agent" );
203+ if (agent != null ) {
204+ agentJarConfig .defaultDependencies (deps -> {
205+ deps .add (project .getDependencies ().project (Map .of ("path" , ":libs:entitlement:agent" , "configuration" , "default" )));
206+ });
207+ }
205208 FileCollection agentFiles = agentJarConfig ;
206209
207210 Configuration bridgeJarConfig = project .getConfigurations ().create ("entitlementBridgeJar" );
208- bridgeJarConfig .defaultDependencies (deps -> {
209- deps .add (project .getDependencies ().project (Map .of ("path" , ":libs:entitlement:bridge" , "configuration" , "default" )));
210- });
211+ Project bridge = project .findProject (":libs:entitlement:bridge" );
212+ if (bridge != null ) {
213+ bridgeJarConfig .defaultDependencies (deps -> {
214+ deps .add (project .getDependencies ().project (Map .of ("path" , ":libs:entitlement:bridge" , "configuration" , "default" )));
215+ });
216+ }
211217 FileCollection bridgeFiles = bridgeJarConfig ;
212218
213219 project .getTasks ().withType (Test .class ).configureEach (test -> {
214220 // See also SystemJvmOptions.maybeAttachEntitlementAgent.
215221
216222 // Agent
217- var systemProperties = test .getExtensions ().getByType (SystemPropertyCommandLineArgumentProvider .class );
218- test .dependsOn (agentFiles );
219- systemProperties .systemProperty ("es.entitlement.agentJar" , agentFiles .getAsPath ());
220- systemProperties .systemProperty ("jdk.attach.allowAttachSelf" , true );
223+ if (agentFiles .isEmpty () == false ) {
224+ var systemProperties = test .getExtensions ().getByType (SystemPropertyCommandLineArgumentProvider .class );
225+ test .dependsOn (agentFiles );
226+ systemProperties .systemProperty ("es.entitlement.agentJar" , agentFiles .getAsPath ());
227+ systemProperties .systemProperty ("jdk.attach.allowAttachSelf" , true );
228+ }
221229
222230 // Bridge
223- String modulesContainingEntitlementInstrumentation = "java.logging,java.net.http,java.naming,jdk.net" ;
224- test .dependsOn (bridgeFiles );
225- // Tests may not be modular, but the JDK still is
226- test .jvmArgs (
227- "--add-exports=java.base/org.elasticsearch.entitlement.bridge=ALL-UNNAMED," + modulesContainingEntitlementInstrumentation
228- );
231+ if (bridgeFiles .isEmpty () == false ) {
232+ String modulesContainingEntitlementInstrumentation = "java.logging,java.net.http,java.naming,jdk.net" ;
233+ test .dependsOn (bridgeFiles );
234+ // Tests may not be modular, but the JDK still is
235+ test .jvmArgs (
236+ "--add-exports=java.base/org.elasticsearch.entitlement.bridge=ALL-UNNAMED," + modulesContainingEntitlementInstrumentation
237+ );
238+ }
229239 });
230240 }
231241
0 commit comments