forked from cloudfoundry/uaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mssql.gradle
49 lines (43 loc) · 1.64 KB
/
mssql.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* ****************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2017] Pivotal Software, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
* ****************************************************************************
*/
import groovy.sql.Sql
apply from: file('shared_versions.gradle')
repositories {
mavenCentral()
}
configurations {
driver
}
dependencies {
driver group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: mssqlVersion
}
URLClassLoader loader = GroovyObject.class.classLoader
configurations.driver.each {File file ->
loader.addURL(file.toURL())
}
task createSQLServerUAA << {
def props = [user: 'sa', password: 'changemeCHANGEME1234!'] as Properties
def url = 'jdbc:sqlserver://localhost:1433;database=master;'
def driver = 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
def sql = Sql.newInstance(url, props, driver)
sql.call('sp_configure \'contained database authentication\', 1')
sql.call('RECONFIGURE')
sql.call('CREATE DATABASE uaa CONTAINMENT = PARTIAL;')
sql.call('USE uaa;')
sql.call('CREATE USER root WITH PASSWORD = \'changemeCHANGEME1234!\';')
sql.call('EXEC sp_addrolemember N\'db_owner\', N\'root\';')
sql.commit()
sql.close()
}