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

Add ability to pass system properties/env vars to test resources service #1065

Merged
merged 1 commit into from
Jan 10, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ private TaskProvider<StartTestResourcesService> createStartServiceTask(Configura
task.getStandalone().set(isStandalone);
task.getClassDataSharingDir().convention(cdsDir);
task.getUseClassDataSharing().convention(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17));
task.getSystemProperties().convention(config.getServerSystemProperties());
task.getEnvironment().convention(config.getServerEnvironment());
task.getDebugServer().convention(config.getDebugServer());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.Input;
Expand Down Expand Up @@ -173,6 +174,12 @@ public abstract class StartTestResourcesService extends DefaultTask {
@Internal
public abstract DirectoryProperty getClassDataSharingDir();

@Input
public abstract MapProperty<String, String> getSystemProperties();

@Input
public abstract MapProperty<String, String> getEnvironment();

@Inject
protected abstract ExecOperations getExecOperations();

Expand Down Expand Up @@ -219,6 +226,8 @@ private void startService(ServerUtils.ProcessParameters processParameters) {
spec.setClasspath(getObjects().fileCollection().from(classpath));
spec.setJvmArgs(processParameters.getJvmArguments());
processParameters.getSystemProperties().forEach(spec::systemProperty);
getSystemProperties().get().forEach(spec::systemProperty);
getEnvironment().get().forEach(spec::environment);
processParameters.getArguments().forEach(spec::args);
});
} catch (GradleException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.micronaut.testresources.buildtools.KnownModules;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;

/**
Expand Down Expand Up @@ -110,4 +111,23 @@ public interface TestResourcesConfiguration extends KnownModules {
* @return the server idle timeout
*/
Property<Integer> getServerIdleTimeoutMinutes();

/**
* System properties to be set on the test resources service JVM.
* @return the system properties
*/
MapProperty<String, String> getServerSystemProperties();

/**
* Environment variables to be set on the test resources service JVM.
* @return the environment variables
*/
MapProperty<String, String> getServerEnvironment();

/**
* Set this property to true if you want to start the test resources service
* with a debugger attached.
* @return the debug property
*/
Property<Boolean> getDebugServer();
}
Loading