This repository has been archived by the owner on Feb 16, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
106 lines (89 loc) · 3.45 KB
/
build.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
plugins {
id "mpern.sap.commerce.build" version "1.0.2"
id "mpern.sap.commerce.ccv1.package" version "1.0.2"
}
//to avoid FQN in your task definitions, import the custom task classes
import mpern.sap.commerce.build.tasks.HybrisAntTask
repositories {
//your company maven repository
maven {
url 'https://repository.company.com/hybris-release'
}
//for DB drivers
jcenter()
}
version = "1.0.0-SNAPSHOT"
hybris {
version = "6.6.0.0"
}
CCV1 {
//let's define en extra 'qa' environment
environments = ['dev', 'qa', 'stag', 'prod']
datahub = true
//since this is just a demo, let's configure a dummy datahub file
datahubWar = file("my-custom-datahub.war")
}
dependencies {
//db drivers defined here are automatically downloaded and configured during bootstrapPlatform
dbDriver "mysql:mysql-connector-java:5.1.45"
}
//Examaple for a local setup:
//treat the hybris/config folder (mostly) like an external dependency
//1. load environment specific configs from hybris.optional.config.dir
task configureOptionalConfigDir {
dependsOn "bootstrapPlatform", "createDefaultConfig"
def localProperties = file('hybris/config/local.properties')
onlyIf {
!localProperties.text.contains("hybris.optional.config.dir")
}
doLast {
localProperties << """
#GENERATED by gradle
hybris.optional.config.dir=${project.file('config/own-config')}
#GENERATED
""".stripIndent()
}
}
//2. only keep modified files in git, and copy them over the out-of-the-box config
task copyCustomConfig(type: Copy) {
group "Setup"
description "Copy modified files over the standard hybris config folder"
dependsOn "bootstrapPlatform", "createDefaultConfig"
from file("config/config-customization/")
into file("hybris/config/")
}
//little helper task to generate a new developer config
task createBootstrapDevConfig(type: WriteProperties) {
def developerProperties = file("config/own-config/99-local.properties")
onlyIf {
!developerProperties.exists()
}
outputFile developerProperties
comment "Generated developer properties, feel free to change"
property "db.url", "jdbc:mysql://localhost:3306/${project.name}?useConfigs=maxPerformance&characterEncoding=utf8&useSSL=false"
property "db.driver", "com.mysql.jdbc.Driver"
property "db.username", "<CHANGE_ME>"
property "db.password", "<CHANGE_ME>"
}
task setupDev {
group "Setup"
description "Create a new Developer Setup from scratch"
dependsOn "copyCustomConfig", "configureOptionalConfigDir", "createBootstrapDevConfig"
}
//the plugin also provides a custom task type to run hybris ant targets
//here an example to run unit tests
task unitTests(type: HybrisAntTask) {
args("unittests")
systemProperty("testclasses.extensions", "training")
//do NOT start hybris for unit tests, works for 6.4+
systemProperty("testclasses.suppress.junit.tenant", "true")
//we can also call other ant targets by prefexing the target name with `y`
//because the plugin defines a task rule (check the output of './gradlew tasks')
dependsOn tasks.getByPath("ybuild")
}
//you can also call any other hybris ant target on the command line with `./gradlew y<target>`
task rebuildAndPackage {
group "Distribution"
description "Rebuild platform and create a new hybris cloud services package"
dependsOn "yclean", "ybuild", "yproduction", "buildCCV1Package"
}