Git Product home page Git Product logo

commerce-gradle-plugin's Introduction

SAP Commerce Gradle Plugins 4.0.0

Actions Status REUSE status

Bootstrap, configure and build your SAP Commerce (Hybris) project using Gradle 5+.

Note
For the user documentation, please check the /docs folder

The plugins are published to https://plugins.gradle.org/.

Published Plugin Documentation Description
sap.commerce.build Documentation Automates the developer setup and allows you to interact with the platform build using Gradle
sap.commerce.build.ccv2 Documentation Use manifest.json to configure and build your "SAP Commerce Cloud in the Public Cloud" (aka CCv2) project locally

This project uses Semantic Versioning 2.0.0

Getting Started

Here is how you get started with the plugins for your SAP Commerce project.

Prerequisites

Install Gradle, in case you haven't yet.

Examples

Minimal Setup for CCv2 Manifest Validation

  1. cd <project>/core-customize

  2. (optional, but highly recommended) Initialize the Gradle Wrapper

    gradle wrapper
  3. Add a minimal Gradle build script:
    build.gradle.kts

    plugins {
        id("sap.commerce.build.ccv2") version("4.0.0")
    }
  4. ./gradlew validateManifest

Development Setup

For a fully automated, best-practice CCv2 project setup, refer to sap-commerce-tools/ccv2-project-template

  1. cd <project>/core-customize

  2. (optional, but highly recommended) Initialize the Gradle Wrapper

    gradle wrapper
  3. Add Gradle build script
    build.gradle.kts

    plugins {
       id("sap.commerce.build") version("4.0.0")
       id("sap.commerce.build.ccv2") version("4.0.0")
    }
    
    repositories {
      //Please refer to the official Gradle documentation and the plugin documentation for additional
      // information about dependency resolution.
    
      // Option 1: Use a (custom) Maven repository to provide SAP Commerce artifacts for development
      maven {
         url = uri("https://custom.repo.com/maven")
      }
      // Option 2: Download all required files manually and put them in `dependencies` folder
      // There are ways to automate the downloads from launchpad.support.sap.com, please check the FAQ.
      // Make sure to rename the files accordingly (<artifactId>-<version>.zip)
      flatDir { dirs("dependencies") }
    
      mavenCentral()
    }
  4. Enjoy things like:

    • ./gradlew bootstrapPlatform - download (if you use Maven) and set up the correct SAP Commerce zip, extension packs, cloud extension packs, ..., as defined in manifest.json
    • ./gradlew installManifestAddons - install all addons as defined in manifest.json
    • ./gradlew yclean yall - run ant clean all using Gradle. You can run any Ant target provided by SAP Commerce as y<target>.
    • ./gradlew validateManifest- validate your manifest for common errors. Now with additional checks because the full platform is available.
    • ./gradlew cloudTests cloudWebTests- run the tests defined in manifest.json

Don't forget to commit the Gradle Wrapper and your build script.

Support

Please raise an issue in this GitHub project, following the guidelines outlined in CONTRIBUTING.md

Contributing

Please refer to CONTRIBUTING.md

commerce-gradle-plugin's People

Contributors

aepfli avatar bechte avatar guiliguili avatar iccaprar avatar mpern avatar tklostermannnsd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

commerce-gradle-plugin's Issues

HybrisAntTask doesn't work with SAP JVM

> Task :createDefaultConfig FAILED
Task ':createDefaultConfig' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command '/SAPDevelop/tools/jdk/sapjvm_8/bin/java''. Working directory: /.../hybris/bin/platform Command: /..//sapjvm_8/bin/java -Dant.home=/.../hybris/bin/platform/apache-ant -Dawt.toolkit=sun.lwawt.macosx.LWCToolkit -Dcom.sap.vm.codeline=81_REL -Dcom.sap.vm.compressedoops=true -Dcom.sap.vm.profilingserver=true -Dcom.sap.vm.type=opt -Dcom.sap.vm.version=10 -Dfile.encoding.pkg=sun.io -Dfile.separator=/ -DgopherProxySet=false -Dinput.template=develop -Djava.awt.graphicsenv=sun.awt.CGraphicsEnvironment -Djava.awt.printerjob=sun.lwawt.macosx.CPrinterJob <a lot more JVM flags> -cp /SAPDevelop/projects/hybris-gradle/sapjvm-test/hybris/bin/platform/apache-ant/lib/ant-launcher.jar org.apache.tools.ant.launch.Launcher -Dmaven.update.dbdrivers=false
Successfully started process 'command '/.../sapjvm_8/bin/java''
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
:createDefaultConfig (Thread[Execution worker for ':',5,main]) completed. Took 0.243 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':createDefaultConfig'.
> Process 'command '/SAPDevelop/tools/jdk/sapjvm_8/bin/java'' finished with non-zero exit value 1

Cloud tests failure should fail the build by default

Currently tests failure on cloud tests execution (cloudTests and cloudWebTests) does not fail the build.

I had to configure it manually :

tasks.named<HybrisAntTask>("cloudTests") {
    antProperty("failbuildonerror", "yes")   
}

Could you please fail the build by default ?

Sparse build slow when building smartedittools

When building smartedittools smartedittools.only.build.once=false, the discovery of existing extensions in the project folder slows a lot (from a few seconds to minutes), because it scans for extensioninfo.xml files in all the node_modules folders.

Simplify removeUnusedExtensions

In

project.getTasks().register("removeUnusedExtensions", t -> {

a task "removeUnusedExtensions" is declared and it uses a FileTreeWalker to remove files and directories. In my local tests, this process always exceeds the memory of the gradle process or it runs for more than 15 minutes, before I actually abort it. 👎

Wouldn't it be easier to compare the content of config/localextensions-generate.xml´ file, generated by ant extensionsxmlwith the files found using a simplefind . -type f -name extensioninfo.xml` from the "bin" directory?

This delta should show the extensioninfo.xml files from the extensions that need to be removed, therefore, removing their parent directory with rm -rf <PATH> should do the trick and should run very fast.

What do you think, @mpern ?

Using ${hybris.version} is not possible

We are currently trying to implement the Gradle Plugin for our Setup and facing the Issue that the Variable "hybris.version" cannot be used.

Gradle Script:

plugins {
    id "sap.commerce.build" version "3.0.0"
    id "sap.commerce.build.ccv2" version "3.0.0"
}

hybris {
    // hybris version to use
    // is preconfigured with commerceSuiteVersion of the manifest
    version = "2005.5"
}

task printVersion {
  println "version: ${hybris.version}"
}

Result:
version: extension 'hybris' property 'version'

expected:
version: 2005.5

workaround
use ${hybris.version.get()}

Investigate slow cleanPlatform w/ Gradle 7.4

something changed about file system access in Gradle 7.x

cleanPlatform is unbearably slow now

  • setup clean test system without any AV scanners etc. interfering
  • benchmark cleanPlatform
  • optimize

Add dependency to bootstrapPlatform for tasks created by HybrisAntRule

As a developper I would like to :

  • Use a unique tool to setup, build and run the platform : Gradle
  • Minimise the number of tasks to execute manually to be able to build and run.
  • Use the latest available SAP Commerce patch version in the Maven repository.

Currently we must run the bootstrapPlatform before running ybuild or any other task created by the
the Task Rule.

Suggestion : Add dependency to bootstrapPlatform for all tasks created by HybrisAntRule. Potentially this could be drive by inclusion/exclusion configuration properties with sensitive default values (include all, exclude none).

Error with default excludes and gradle >= 6.7

Hi,

the removeUnusedExtensions task seems to be not working with gradle >=6.7:
Cannot change default excludes during the build. They were changed from [**/#*#, **/%*%, **/*~, **/.#*, **/.DS_Store, **/._*, **/.bzr, **/.bzr/**, **/.bzrignore, **/.cvsignore, **/.git, **/.git/**, **/.gitattributes, **/.gitignore, **/.gitmodules, **/.hg, **/.hg/**, **/.hgignore, **/.hgsub, **/.hgsubstate, **/.hgtags, **/.svn, **/.svn/**, **/CVS, **/CVS/**, **/SCCS, **/SCCS/**, **/vssver.scc] to []. Configure default excludes in the settings script instead.

Here is the changelog for this:
https://docs.gradle.org/current/userguide/upgrading_version_6.html#changing_default_excludes_during_the_execution_phase

sap.commerce.build 3.9.0 not compatible with 2211.7 (FP1)

The sap.commerce.build fails to invoke ant-tasks when using the latest sap commerce version 2211.7.

The version 2211.6 uses the version number "version=2211.6" in bin/platform/build.number
The version 2211.7 uses "version=2211.FP1". The "FP1" gets converted to a number and fails the build.

error message for input string "FP1"

Automating downloads from launchpad with CI

I am not sure if this is even the right place to ask, if not, please let me know, where i should instead ask :)

I want to download the SAP Commerce artifacts via CI so i can easier distribute them with my co workers. We are using a Package Registry tool for storing most of our artifacts. To reduce the overhead, we thought it is a good ides to use our CI infrastructure to download via CURL and store it in the Package registry.

Sadly this seems to be not working, i assume it is related to our infrastructure within GCP. But if i use the same docker image locally for downloading, i have no issues at all downloading. But if i use it with the CI system, i am always redirected to a page via AkamaiGHost and my first request is a Temporarly Moved request.

I thought i ask here based on https://github.com/SAP/commerce-gradle-plugin/blob/master/docs/FAQ.md#faq - as this was my main orientation for the tooling. Maybe somebody else already had this problem, and found a solution.

Thank you

ccv2 plugin may fail parsing manifest.json

If you the project uses a very minimal manifest (without storefrontAddons, properties or aspects) applying the plugin will fail with NPEs

Workaround (for now):

add empty arrays for any of the above keys

{
    "commerceSuiteVersion": "1811.3",
    "extensions": [
        ...
    ],
    "storefrontAddons": [],
    "properties": [],
    "aspects": []
}

HybrisAntTask.setMain() fails for yclean

I am trying to use your plugin to setup Commerce 2211 using Gradle 8.2.1 and Java 17

I noticed this failed

  • What went wrong: Execution failed for task ':yclean'.
    Failed to notify task execution listener.
    'org.gradle.api.tasks.JavaExec mpern.sap.commerce.build.tasks.HybrisAntTask.setMain(java.lang.String)'

And that's due to the fact that Gradle is migrating many tasks over to Property<String>. Specifically getMainClass().set(string) should be used instead.

https://docs.gradle.org/8.2.1/javadoc/org/gradle/process/JavaExecSpec.html#setMain-java.lang.String-

More precisely, we're using SAP's Gradle plugin and extending it to support the functionality that we want for our proprietary plugin.

Gradle 5.0 compatibility

  • FileCollection.stopExecutionIfEmpty() not available anymore -> CloudServicesPackagingPlugin.java needs a different way to fail when the required files for the package aren't available

Spring Cleaning 2023

  • Update GH Actions to latest versions
  • Update Gradle
  • Update Gradle Plugins
  • Java 17 -> drop support for all Gradle versions < 7.6
  • Update build script: use use kotlin script
  • Split codebase into subprojects:
    • [ ] platform utils
    • test utils (replaces commonTest source set)
    • build plugin
    • ccv2 plugin
  • remove ccv1 plugin

Issue with CCV2 and 1811

Hi,

It seems SAP has changed (again) the way of versioning hybris.

While for the manifest we need to set:
"commerceSuiteVersion": "1811",

On platform/build.number we get
version=18.11

This causes that every time we do a .gradlew bootstrapPlatform the plugin detects that the version have changed:
current version: 18.11; required version: 1811

This happens even if we configure hybris.version in our build.gradle, so the version on the manifest seems to have preference over the configuration. IMHO, this should be the other way around.

hybris {
    version = '18.11'
}

Regards

Gradle 6.x support

The plugin API needs to be upgraded to support current gradle releases.

This will remove support for all versions smaller than 5, IIRC

Improvement : Pass ant property via command line

It would be really cool if we could pass ant properties via Command line, e.g. :

$ gradle -DantProperty.build.parallel=true -DantProperty.build.development.mode=true ybuild

and/or

$ gradle -DantProperties=build.parallel=true,build.development.mode=true ybuild # need to escape ',' in ant properties ;)

Support for SAP Commerce 2105

Hello, I really like your plugin and want to use it for a new project, but unfortunately in your IntExtPackValidator there are the new sap commerce version 2105 and the new int ext pack version 2108 missing. Can you please add them?
I tried to open a Pull Request, but I don't have permissions for this.

DefaultTask is created for cloud tests when no test configuration is defined

This is highlighted when configuring cloudTests and/ro cloudWebTests tasks when no test configuration is defined in the manifest :

tasks.named<HybrisAntTask>("cloudWebTests") {
    antProperty("failbuildonerror", "yes")   
}
$ ./gradlew cloudWebTests                                                                                

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/i303934/SAPDevelop/Projects/LaPoste/git/phoenix-commerce/core-customize/build.gradle.kts' line: 59

* What went wrong:
The task 'cloudWebTests' (org.gradle.api.DefaultTask) is not a subclass of the given type (mpern.sap.commerce.build.tasks.HybrisAntTask).

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

HybrisAntTask xPath error in new SAP commerce version 2205

The hybris ant task throws the error java.lang.IllegalAccessError: class com.oopsconsultancy.xmltask.jdk15.XPathAnalyser15 (in unnamed module @0x67f946c3) cannot access class com.sun.org.apache.xpath.internal.XPathAPI (in module java.xml) because module java.xml does not export com.sun.org.apache.xpath.internal to unnamed module @0x67f946c3 when trying to install addons with the new version 2205. In fact every ant task that uses the "xmltask" task gets this error.
When trying to install the addon the old way with ". ./setantenv.sh" and "ant addoninstall" command everything works.

These are the added ANT_OPTS in setantenv.sh:
-Dpolyglot.js.nashorn-compat=true -Dpolyglot.engine.WarnInterpreterOnly=false
--add-exports java.xml/com.sun.org.apache.xpath.internal=ALL-UNNAMED
--add-exports java.xml/com.sun.org.apache.xpath.internal.objects=ALL-UNNAMED

manifest validation fails for 2211

Plugin version: 3.7.1.

Running the validateManifest task on a manifest for SAP CC 2211 (2211.1) with Integration Extension Pack 2211.0 fails with the error:

ERROR E-019 @ extensionPacks[0] No Integration Extension Pack available for SAP Commerce 2211.1

Looking in IntExtPackValidator, seems like the new version 2211 is not supported so far.

I will add the fix and submit a code patch.

Only keep required extensions

Only keep (or extract, if possible) extensions that are used by the project, not the whole commerce zip file

Reduces size of the project on disk and help experts involved in different projects simultaneously.

Additionally, provide a way to update the project to remove all unused extensions and add new ones after changing localextensions.xml and/or manifest.json

Mismatched Image Version Validation Issue.

Hello,

I'm encountering an issue with the sap.commerce.build.ccv2:4.0.0 plugin that validates the image version of an sap commerce before building. The plugin is currently unable to handle versions of SAP CC later than 2211. I specifically reproduce this issue with the version 2211.8 of SAP CC

Steps to Reproduce:

Include the in your Gradle build configuration.
Attempt to build the project with the version 2211.8
Observe that the plugin is reporting a version mismatch error even though the build number is the same being used in the cloud portal

Expected Behavior:

The plugin should correctly validate the image version of the artifact

Actual Behavior:
The plugin consistently reports a version mismatch error

Additional Information:

sap.commerce.build.ccv2 version: 4.0.0
SAP Commerce version with mismatched build number:2211.8
Expected build number: 2211.FP1

Any relevant logs or error messages: current version: 2211.FP1 (PREVIEW); required version: 2211.8 -> MISMATCH

portal-build-logs.txt

Environment:

Operating System: Mac OS
Java Version: OpenJDK Runtime Environment SapMachine (build 17.0.8+7-LTS-sapmachine)
Gradle Version: Gradle 7.6

Best regards,
Youssef El Jaoujat

plugin 3.9.1 always extracts 2211.8 from scratch

The change done for #48 allows the build to complete, but it does a platform cleanup + extract for each build.

This is because SAP left the release 2211.8 still named 2211.FP1 in the platform version.properties, but in the manifest.json, the platform version must be set to 2211.8, not 2211.FP1, otherwise the build fails in CCv2.

If we want to run the build in CCv2 (and we do :) ), then we cannot name the dependency 2211.FP1, so we always get the cleanup+bootstap.

We need to map 2211.FP1 to 2211.8 in the plugin version parsing.

I will submit a patch.

ccv1 packaging: declare task inputs and outputs

Declare the task inputs and outputs of buildCCV1Package to make it easier to work with the task.

Declaring the outputs makes it easy to "post-process" the generated deployment package and checksum file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.