1- import org.apache.tools.ant.taskdefs.condition.Os
2-
3- import de.undercouch.gradle.tasks.download.Download
4- import de.undercouch.gradle.tasks.download.VerifyAction
5-
6- import java.time.Instant
71import java.util.Base64
82
93plugins {
@@ -13,233 +7,18 @@ plugins {
137 `maven- publish`
148}
159
16- val solrVersionMap = mapOf (
17- /*
18- * version 8 unfortunately has a different download URL and is currently not working. But it is the version that is
19- * supplied with the standard zip, so we're fine unless the solr version is changed and then changed back in
20- * manifest.json
21- */
22- " 8.11" to " 8.11.2" ,
23- " 9.2" to " 9.2.1" ,
24- " 9.5" to " 9.5.0"
25- )
26-
27- val dependencyDir = " ../dependencies"
28- val workingDir = project.projectDir
29- val binDir = " ${workingDir} /hybris/bin"
30-
3110repositories {
32- flatDir { dirs(dependencyDir) }
11+ mavenLocal()
3312 mavenCentral()
3413}
3514
36- val solrVersion = solrVersionMap[CCV2 .manifest.solrVersion] ? : " 9.2.1"
37- val solrServer: Configuration by configurations.creating
38-
39- dependencies {
40- solrServer(" org.apache.solr:solr:${solrVersion} " )
41- }
42-
43- hybris {
44- // what files should be deleted when cleaning up the platform?
45- // (cloudhofolders will be downloaded by custom configuration)
46- cleanGlob.set(" glob:**hybris/bin/{modules**,platform**,cloudhotfolders**}" )
47-
48- // what should be unpacked from the platform zip files?
49- bootstrapInclude.set(
50- listOf (
51- " hybris/**" , //
52- " azurecloudhotfolder/**" , //
53- " cloudcommons/**" , //
54- " cloudhotfolder/**" //
55- )
56- )
57-
58- // what should excluded when unpacking?
59- // the default value is a npm package folder that includes UTF-8 filenames, which lead to problems on linux
60- bootstrapExclude.set(
61- listOf (
62- " hybris/bin/ext-content/npmancillary/resources/npm/node_modules/http-server/node_modules/ecstatic/test/**"
63- )
64- )
65-
66- // Control the sparse platform bootstrap.
67- // When enabled, the commerce extensions are extracted from the distribution zip on a as-needed basis.
68- // Only extensions that are actually used in the project (either directly listed in the localextensions.xml or
69- // required by other extensions) are extracted.
70- // The platform itself is always extracted.
71- // When this mode is enabled, the bootstrapInclude configuration property is ignored.
72- sparseBootstrap {
73- enabled = true
74- alwaysIncluded = listOf<String >(" solrserver" )
75- }
76- }
77-
78- tasks.register<Download >(" fetchSolr" ) {
79- src(uri(" https://archive.apache.org/dist/solr/solr/${solrVersion} /solr-${solrVersion} .tgz" ))
80- dest(" ${dependencyDir} /solr-${solrVersion} .tgz" )
81- overwrite(false )
82- }
83-
84- val repackSolr = tasks.register<Zip >(" repackSolr" ) {
85- dependsOn(" fetchSolr" )
86- from(tarTree(" ${dependencyDir} /solr-${solrVersion} .tgz" ))
87- archiveFileName = " solr-${solrVersion} .zip"
88- destinationDirectory = file(dependencyDir)
89- }
90-
91- publishing {
92- publications {
93- create<MavenPublication >(" solr" ) {
94- groupId = " org.apache.solr"
95- artifactId = " solr"
96- version = solrVersion
97-
98- artifact(repackSolr.get().archiveFile)
99- }
100- }
101- }
102-
103- tasks.named(" yinstallSolr" ) {
104- // this task is available because of the solr-publication above.
105- dependsOn(" publishSolrPublicationToMavenLocal" )
106- }
107-
108- tasks.ybuild {
109- dependsOn(" publishSolrPublicationToMavenLocal" )
110- group = " build"
111- }
112-
113- if (project.hasProperty(" CXDEV_ARTEFACT_BASEURL" ) && project.hasProperty(" CXDEV_ARTEFACT_USER" ) && project.hasProperty(" CXDEV_ARTEFACT_PASSWORD" )) {
114- val BASEURL = project.property(" CXDEV_ARTEFACT_BASEURL" ) as String
115- val USER = project.property(" CXDEV_ARTEFACT_USER" ) as String
116- val PASSWORD = project.property(" CXDEV_ARTEFACT_PASSWORD" ) as String
117- val AUTHORIZATION = Base64 .getEncoder().encodeToString((USER + " :" + PASSWORD ).toByteArray())
118-
119- val COMMERCE_VERSION = CCV2 .manifest.effectiveVersion
120- tasks.register<Download >(" downloadPlatform" ) {
121- val targetFile = file(" ${dependencyDir} /hybris-commerce-suite-${COMMERCE_VERSION } .zip" )
122-
123- src(" $BASEURL /commerce/hybris-commerce-suite-${COMMERCE_VERSION } .zip" )
124- dest(targetFile)
125-
126- header(" Authorization" , " Basic $AUTHORIZATION " )
127-
128- overwrite(false )
129- tempAndMove(true )
130- onlyIfModified(true )
131- useETag(true )
132-
133- doFirst {
134- logger.lifecycle(" === Download Platform Debug ===" )
135- logger.lifecycle(" Source URL: $BASEURL /commerce/hybris-commerce-suite-${COMMERCE_VERSION } .zip" )
136- logger.lifecycle(" Destination: ${targetFile.absolutePath} " )
137- logger.lifecycle(" Destination exists: ${targetFile.exists()} " )
138- logger.lifecycle(" Dependency dir: ${file(dependencyDir).absolutePath} " )
139-
140- if (file(dependencyDir).exists()) {
141- logger.lifecycle(" Directory content:" )
142- file(dependencyDir).listFiles()?.forEach {
143- logger.lifecycle(" - ${it.name} " )
144- }
145- }
146- }
147-
148- doLast {
149- logger.lifecycle(" === Download completed ===" )
150- logger.lifecycle(" File exists after download: ${targetFile.exists()} " )
151- logger.lifecycle(" File size: ${targetFile.length()} " )
152-
153- logger.lifecycle(" Dependency dir: ${file(dependencyDir).absolutePath} " )
154-
155- if (file(dependencyDir).exists()) {
156- logger.lifecycle(" Directory content:" )
157- file(dependencyDir).listFiles()?.forEach {
158- logger.lifecycle(" - ${it.name} " )
159- }
160- }
161- }
162- }
163-
164- tasks.named(" bootstrapPlatform" ) {
165- dependsOn(" downloadPlatform" )
166- }
167-
168- // check if Integration Extension Pack is configured and download it too
169- if (CCV2 .manifest.extensionPacks.any{" hybris-commerce-integrations" .equals(it.name)}) {
170- val INTEXTPACK_VERSION = CCV2 .manifest.extensionPacks.first{" hybris-commerce-integrations" .equals(it.name)}.version
171- tasks.register<Download >(" downloadIntExtPack" ) {
172- src(BASEURL + " /integration/hybris-commerce-integrations-${INTEXTPACK_VERSION } .zip" )
173- dest(file(" ${dependencyDir} /hybris-commerce-integrations-${INTEXTPACK_VERSION } .zip" ))
174- header(" Authorization" , " Basic ${AUTHORIZATION } " )
175- overwrite(false )
176- tempAndMove(true )
177- onlyIfModified(true )
178- useETag(true )
179- }
180-
181- tasks.named(" bootstrapPlatform" ) {
182- dependsOn(" downloadIntExtPack" )
183- }
184- }
185- }
186-
187- tasks.register<WriteProperties >(" generateLocalProperties" ) {
188- comment = " GENERATED AT " + Instant .now()
189- destinationFile = project.file(" hybris/config/local.properties" )
190- property(" hybris.optional.config.dir" , project.file(" hybris/config/local-config" ).absolutePath)
191- doLast {
192- mkdir(project.file(" hybris/config/local-config/" ))
193- }
194- }
195-
196- val symlinkConfigTask: TaskProvider <Task > = tasks.register(" symlinkConfig" )
197- val localConfig = file(" hybris/config/local-config" )
198- mapOf (
199- " 10-local.properties" to file(" hybris/config/cloud/common.properties" ),
200- " 20-local.properties" to file(" hybris/config/cloud/persona/development.properties" ),
201- " 50-local.properties" to file(" hybris/config/cloud/local-dev.properties" )
202- ).forEach{
203- val symlinkTask = tasks.register<Exec >(" symlink${it.key} " ) {
204- val path = it.value.relativeTo(localConfig)
205- if (Os .isFamily(Os .FAMILY_UNIX )) {
206- commandLine(" sh" , " -c" , " ln -sfn $path ${it.key} " )
207- } else {
208- // https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/
209- val windowsPath = path.toString().replace(" [/]" .toRegex(), " \\ " )
210- commandLine(" cmd" , " /c" , """ mklink "${it.key} " "$windowsPath " """ )
211- }
212- workingDir(localConfig)
213- dependsOn(" generateLocalProperties" )
214- }
215- symlinkConfigTask.configure {
216- dependsOn(symlinkTask)
217- }
218- }
219-
220- tasks.register<WriteProperties >(" generateLocalDeveloperProperties" ) {
221- dependsOn(symlinkConfigTask)
222- comment = " my.properties - add your own local development configuration parameters here"
223- destinationFile = project.file(" hybris/config/local-config/99-local.properties" )
224- onlyIf {
225- ! project.file(" hybris/config/local-config/99-local.properties" ).exists()
226- }
227- }
228-
229- // https://help.sap.com/viewer/b2f400d4c0414461a4bb7e115dccd779/LATEST/en-US/784f9480cf064d3b81af9cad5739fecc.html
230- tasks.register<Copy >(" enableModeltMock" ) {
231- from(" hybris/bin/custom/extras/modelt/extensioninfo.disabled" )
232- into(" hybris/bin/custom/extras/modelt/" )
233- rename { " extensioninfo.xml" }
234- }
235-
236- tasks.named(" installManifestAddons" ) {
237- mustRunAfter(" generateLocalProperties" )
238- }
15+ apply (from = " gradle/commerce-artifacts.gradle.kts" )
16+ apply (from = " gradle/solr.gradle.kts" )
17+ apply (from = " gradle/localdev.gradle.kts" )
23918
24019tasks.register(" setupLocalDevelopment" ) {
241- group = " SAP Commerce"
242- description = " Setup local development "
20+ group = " SAP Commerce Cloud "
21+
24322 dependsOn(
24423 " bootstrapPlatform" ,
24524 " yinstallSolr" ,
0 commit comments