Skip to content

Commit 0c25481

Browse files
committed
#453 mlInstallAdmin now supports a realm property
1 parent 3a1a5fc commit 0c25481

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

examples/sample-project/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mlTestRestPort=8101
1313

1414
# You can define just mlUsername and mlPassword, and that user will be used for all deployment operations, but that's
1515
# generally not a good practice, as this user will need the admin role in order to create security resources. Generally,
16-
# you want to use an admin user just for mlAdminUsername, as that username will only be used for creating security
16+
# you want to use an admin user just for mlSecurityUsername, as that username will only be used for creating security
1717
# resources such as users and roles. You can then use app-specific users for mlRestAdminUsername, mlManageUsername, etc.
1818
#
1919
# Otherwise, this is typically an application user. In sample-project, this user is used for running JUnit tests.

src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class MarkLogicPlugin implements Plugin<Project> {
111111

112112
String adminGroup = "ml-gradle Admin"
113113
project.task("mlInit", type: InitTask, group: adminGroup, description: "Perform a one-time initialization of a MarkLogic server; uses the properties 'mlLicenseKey' and 'mlLicensee'")
114-
project.task("mlInstallAdmin", type: InstallAdminTask, group: adminGroup, description: "Perform a one-time installation of an admin user; uses the properties 'mlAdminUsername'/'mlUsername' and 'mlAdminPassword'/'mlPassword'")
114+
project.task("mlInstallAdmin", type: InstallAdminTask, group: adminGroup, description: "Perform a one-time installation of an admin user; uses the properties 'mlAdminUsername'/'mlUsername' and 'mlAdminPassword'/'mlPassword'; " +
115+
"the realm, which defaults to 'public', can optionally be specified on the command line via '-Prealm='")
115116

116117
String alertGroup = "ml-gradle Alert"
117118
project.task("mlDeleteAllAlertConfigs", type: DeleteAllAlertConfigsTask, group: alertGroup, description: "Delete all alert configs, which also deletes all of the actions rules associated with them")

src/main/groovy/com/marklogic/gradle/task/MarkLogicTask.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ class MarkLogicTask extends DefaultTask {
3636
getProject().property("mlAdminManager")
3737
}
3838

39+
// TODO Should remove this as "mlSecurityUsername" is preferred, and this is now specific to InstallAdminTask
40+
@Deprecated
3941
String getAdminUsername() {
4042
project.hasProperty("mlAdminUsername") ? project.property("mlAdminUsername") : project.property("mlUsername")
4143
}
4244

45+
// TODO Should remove this as "mlSecurityUsername" is preferred, and this is now specific to InstallAdminTask
46+
@Deprecated
4347
String getAdminPassword() {
4448
project.hasProperty("mlAdminPassword") ? project.property("mlAdminPassword") : project.property("mlPassword")
4549
}

src/main/groovy/com/marklogic/gradle/task/admin/InstallAdminTask.groovy

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ import com.marklogic.gradle.task.MarkLogicTask
66

77
class InstallAdminTask extends MarkLogicTask {
88

9+
String realm
10+
911
@TaskAction
1012
void installAdmin() {
11-
getAdminManager().installAdmin(getAdminUsername(), getAdminPassword())
13+
if (getProject().hasProperty("realm")) {
14+
realm = project.property("realm")
15+
}
16+
if (realm != null) {
17+
getAdminManager().installAdmin(getAdminUsername(), getAdminPassword(), realm)
18+
} else {
19+
getAdminManager().installAdmin(getAdminUsername(), getAdminPassword())
20+
}
1221
}
1322
}

0 commit comments

Comments
 (0)