Skip to content

Commit

Permalink
Add parameter to dev extension and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking committed Aug 30, 2024
1 parent 19c2aba commit 6330a7b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
33 changes: 32 additions & 1 deletion docs/libertyDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ The following are optional command line parameters supported by this task.

| Parameter | Description | Required |
| -------- | ----------- | ------- |
| changeOnDemandTestsAction | If this option is enabled, change the action for running on demand tests from `Enter` to type `t` and press `Enter`. The default value is `false`. This parameter is introduced in version 3.8.4. | No |
| compileWait | Time in seconds to wait before processing Java changes. If you encounter compile errors while refactoring, increase this value to allow all files to be saved before compilation occurs. The default value is `0.5` seconds. | No |
| generateFeatures | If set to `true`, when a Java file, server configuration file, or build file is changed, generate features required by the application in the source configuration directory. The default value is `false`. | No |
| hotTests | If this option is enabled, run tests automatically after every change. The default value is `false`. | No |
Expand All @@ -75,8 +74,40 @@ The following are optional command line parameters supported by this task.

### Properties

The `dev` extension allows you to configure properties for the `libertyDev` task.

These can also be specified as command line parameters in addition to the ones in the section above.

| Attribute | Type | Since | Description | Required |
| --------- | ----- | ----- | ----------- | -------- |
| changeOnDemandTestsAction | boolean | 3.8.4 | If set to `true`, change the action for running on demand tests from `Enter` to type `t` and press `Enter`. The default value is `false`. | No |

See the [Liberty server configuration](libertyExtensions.md#liberty-server-configuration) properties for common server configuration.

### Examples

Start dev mode and change the on demand tests action from `Enter` to type `t` and press `Enter`.
```
$ gradle libertyDev --changeOnDemandTestsAction
```

Customizing the configuration using `dev` extension properties in `build.gradle`. Note that changing these while dev mode is running is not supported.
```
liberty {
dev {
changeOnDemandTestsAction = true
}
}
```

or

```
ext {
liberty.dev.changeOnDemandTestsAction = true
}
```

### System Properties for Tests

Tests can read the following system properties to obtain information about the Liberty server.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2020, 2023.
* (C) Copyright IBM Corporation 2020, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@ class DevExtension {
int containerBuildTimeout
boolean skipDefaultPorts = false
boolean keepTempContainerfile = false
boolean changeOnDemandTestsAction = false

//Docker aliases to maintain backwards compatability
File dockerfile
Expand Down
20 changes: 13 additions & 7 deletions src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class DevTask extends AbstractFeatureTask {
@Option(option = 'changeOnDemandTestsAction', description = 'If this option is enabled, change the action for running on demand tests from Enter to type t and press Enter. The default value is false.')
void setChangeOnDemandTestsAction(boolean changeOnDemandTestsAction) {
this.changeOnDemandTestsAction = changeOnDemandTestsAction;
project.liberty.dev.changeOnDemandTestsAction = this.changeOnDemandTestsAction;
}

private Boolean hotTests;
Expand Down Expand Up @@ -1174,10 +1175,6 @@ class DevTask extends AbstractFeatureTask {
libertyDebugPort = DEFAULT_DEBUG_PORT;
}

if (changeOnDemandTestsAction == null) {
changeOnDemandTestsAction = DEFAULT_CHANGE_ON_DEMAND_TESTS_ACTION;
}

if (hotTests == null) {
hotTests = DEFAULT_HOT_TESTS;
}
Expand All @@ -1202,7 +1199,7 @@ class DevTask extends AbstractFeatureTask {
skipInstallFeature = DEFAULT_SKIP_INSTALL_FEATURE;
}

processContainerParams();
processDevExtensionParams();
}

@TaskAction
Expand Down Expand Up @@ -1443,8 +1440,8 @@ class DevTask extends AbstractFeatureTask {
}
}

// Get container option values from build.gradle if not specified on the command line
private void processContainerParams() throws Exception {
// Get dev extension parameter values from build.gradle if not specified on the command line
private void processDevExtensionParams() throws Exception {
// process parameters from dev extension
if (container == null) {
boolean buildContainerSetting = project.liberty.dev.container; // get from build.gradle or from -Pdev_mode_container=true
Expand Down Expand Up @@ -1497,6 +1494,15 @@ class DevTask extends AbstractFeatureTask {
setKeepTempContainerfile(DEFAULT_KEEP_TEMP_CONTAINERFILE);
}
}

if (changeOnDemandTestsAction == null) {
boolean buildChangeOnDemandTestsActionSetting = project.liberty.dev.changeOnDemandTestsAction; // get from build.gradle
if (buildChangeOnDemandTestsActionSetting == null) {
setChangeOnDemandTestsAction(DEFAULT_CHANGE_ON_DEMAND_TESTS_ACTION);
} else {
setChangeOnDemandTestsAction(buildChangeOnDemandTestsActionSetting);
}
}
}

ProjectConnection initGradleProjectConnection() {
Expand Down

0 comments on commit 6330a7b

Please sign in to comment.