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 0
/
build.gradle.kts
147 lines (126 loc) · 6.33 KB
/
build.gradle.kts
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//to avoid FQN in your task definitions, import the custom task classes
import mpern.sap.commerce.build.tasks.HybrisAntTask
import mpern.sap.commerce.build.tasks.SupportPortalDownload
plugins {
id("mpern.sap.commerce.build") version("1.3.0")
id("mpern.sap.commerce.ccv1.package") version("1.3.0")
}
val platformFiles by extra { "hybris-platform" }
repositories {
flatDir { dirs(platformFiles) }
jcenter()
}
version = "1.0.0-SNAPSHOT"
val hybrisVersion = "1808.5"
hybris {
version.set(hybrisVersion)
}
CCV1 {
//let's define en extra 'qa' environment
environments.set(listOf("dev", "qa", "stag", "prod"))
datahub.set(true)
datahubWar.set(file("my-custom-datahub.war"))
}
dependencies {
//db drivers defined here are automatically downloaded and configured during bootstrapPlatform
dbDriver("mysql:mysql-connector-java:5.1.47")
//if you want to unpack additional artifacts during bootstrapPlatform, defined them here
hybrisPlatform("de.hybris.platform:hybris-commerce-suite:${hybrisVersion}@zip")
hybrisPlatform("de.hybris.platform:hybris-commerce-datahub:${hybrisVersion}@zip")
}
//from gradle.properties
val supportUser: String by project
val supportPassword: String by project
tasks {
//Example for downloading the zips from the support portal
//The SupportPortalDownload tasks below download the files in the same folder that is configured for
//dependency resolution (variable platformFiles), so the bootstrapPlatform task
//can use them to unpack the platform
//The plugin makes sure to execute any SupportPortalDownload task before the
//bootstrapPlatform task, to avoid dependency resolution errors.
register<SupportPortalDownload>("downloadCommerce") {
description = "Download hybrisplatform zip file from SAP Support Portal"
//URL to support portal file (as stated in wiki.hybris.com)
supportPortalUrl.set("https://launchpad.support.sap.com/#/softwarecenter/template/products/%20_APP=00200682500000001943&_EVENT=DISPHIER&HEADER=Y&FUNCTIONBAR=N&EVENT=TREE&NE=NAVIGATE&ENR=73555000100200008593&V=MAINT&TA=ACTUAL&PAGE=SEARCH/HYBRIS%20COMMERCE%201808")
//S/I/D User, credentials are defined in gradle.properties
username.set(supportUser)
password.set(supportPassword)
//download target
targetFile.set(file("$platformFiles/hybris-commerce-suite-${hybrisVersion}.zip"))
//expected md5 hash (Available in support portal, Related Info -> Content Info)
sha256Sum.set("caf17547a92ef7220ec99ef6f87727db37eef310fbf99473fd632d1ecd01038f")
}
register<SupportPortalDownload>("downloadDatahub") {
description = "Download datahub zip file from SAP Support Portal"
supportPortalUrl.set("https://launchpad.support.sap.com/#/softwarecenter/template/products/%20_APP=00200682500000001943&_EVENT=DISPHIER&HEADER=Y&FUNCTIONBAR=N&EVENT=TREE&NE=NAVIGATE&ENR=73555000100200008592&V=MAINT&TA=ACTUAL&PAGE=SEARCH/HYBRIS%20DATAHUB%201808")
username.set(supportUser)
password.set(supportPassword)
targetFile.set(file("$platformFiles/hybris-commerce-datahub-${hybrisVersion}.zip"))
sha256Sum.set("36f2e33ddac56470800e2b8f7ad3eba4707dbcc363b1c1b0d48eeeadc6957d9b")
}
//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
val configureOptionalConfigDir by registering {
dependsOn("bootstrapPlatform", "createDefaultConfig")
val localProperties = file("hybris/config/local.properties")
onlyIf {
!localProperties.readText().contains("hybris.optional.config.dir")
}
doLast {
localProperties.appendText("""
#GENERATED by gradle
hybris.optional.config.dir=${project.file("config/own-config")}
#GENERATED
""".trimIndent())
}
}
//2. only keep modified files in git, and copy them over the out-of-the-box config
val copyCustomConfig by registering(Copy::class) {
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
val createBootstrapDevConfig by registering(WriteProperties::class) {
val 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>")
}
val setupDev by registering {
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
val unitTests by registering(HybrisAntTask::class) {
group = "Build"
description = "Run unit tests"
args("unittests")
antProperty("testclasses.extensions", "training")
//do NOT start hybris for unit tests, works for 6.4+
//check https://jira.hybris.com/browse/ECP-1200
antProperty("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 'gradle tasks')
dependsOn(named("ybuild"))
}
//FYI, you can also call any other hybris ant target on the command line with `./gradlew y<target>`
// example of a custom task to run the complete hybris build and generate the
// CCv1 package at the end
val rebuildAndPackage by registering {
group = "Distribution"
description = "Rebuild platform and create a new hybris cloud services package"
dependsOn("yclean", "ybuild", "yproduction", "buildCCV1Package")
}
}