This cookbook gives practical advise on how to develop using Gradle and Intershop build and deployment tools. The target audience are developers of Intershop customer projects and partners. Knowledge ofConcept - Continuous Delivery Tools (valid to 7.10)is assumed.
This cookbook presents a directory setup and a workflow, that is optimized for a single project.
Names in angle brackets
Upper case names in angle brackets like <SERVER> are references to environment variables. Replace them by the proper OS-dependent syntax, e.g., %SERVER%
on Windows or $SERVER
on Linux. The environment variables are set by the gradle_environment.bat or gradle_environment.sh scripts (see recipesSetup a Development EnvironmentandRun Gradle Tasks).
Before a single developer can set up an environment, a few things have to be set up first for the team. The required team setup is out of scope of this cookbook. Such information is included in:
Cookbook - Gradle Assembly Tools- Create an assembly
Also known as source control, source code management systems (SCM), or revision control systems (RCS). VCS is a mechanism for keeping multiple versions of your files, so that when you modify a file you can still access the previous revisions. Place, where build and package software components are located. Provide a common interface to a dependency management system.Phrase Meaning Version Control System (VCS) Artifact Repository Code Analysis Process to analyze source code to calculate metrics, find bugs, etc. Continuous Delivery Pipeline Sometimes called Deployment Pipeline, describes the stages, which code artifacts runs through source to production system. System Component A software package of different code artifacts and files, that have to be deployed together. System Component Set Is a container for system components, that needs to be build and branched together. Assembly An assembly references one or more system components residing in the same or a configured artifact repository in order to deploy or deliver them together. Build Process Compiles and packages files and code artifacts from a source project to deployable artifacts. Publish Process The process which transfers the deployable artifacts to a configured artifact repository. Assembly Process This process combines several system components to an assembly. Deployment Process This process extracts files and code artifacts from an artifact repository and applies the configuration. Project Gradle Distribution This is a customized Gradle distribution with the preconfigured artifact repositories and Gradle plugins. Gradle Plugin A Gradle plugin packages up reusable pieces of build logic, which can be used across many different projects and builds. Project Gradle Plugin This is a Gradle plugin which contains special corporate respectively project settings. Corporate Plugin The term is used as a synonym for Project Gradle Plugin. Gradle Extension Object Java Bean compliant class holding configurations for Gradle plugins. Gradle Wrapper The Gradle Wrapper is the preferred way of starting a Gradle build. The wrapper is a batch script on Windows, and a shell script for other operating systems. When you start a Gradle build via the wrapper, Gradle will be automatically downloaded and used to run the build. See for more information The Gradle Wrapper in the Gradle documentation (2.11, 2.7, 2.3, 2.0, 1.8) Intershop Cluster A number of hosts of different types serving an Intershop 7. Cluster Node One separately deployable part of an Intershop cluster. A host can run multiple nodes of one Intershop cluster.
I want to develop on Intershop 7.8 CI or later. How do I get a Gradle-based development environment?
Ensure thepreconditionsare fulfilled before starting the development.
Setting up a development environments consists of the following steps:
The following steps provide you with a jump start without further ado. See discussion for further details.
Since command line syntax onCookbook - Gradle Developer Workflow#WindowsandCookbook - Gradle Developer Workflow#Linuxslightly differs, the steps are provided once for Windows and once for Linux. Except for the command line syntax both are equivalent.
# | Action | Explanation |
---|---|---|
1 | Check if the minimum system requirements are fulfilled.
Additionally to the general requirements:
| By default, the gradle_environment.bat (see next step) expects the Intershop Studio executable to be installed at C:\intershop\IntershopStudio\IntershopStudio.exe. If your Intershop Studio is located elsewhere adapt the line defining openStudio in gradle_environment.bat accordingly. |
2 | Create an empty directory to contain your development environment. Check out the project from your VCS to the directory (as generated at <sources>/projects/<project name> inCookbook - Setup of CI Infrastructure). | The partition/drive should have enough space/speed to hold your sources, a deployed server and the size of a deployed server caches for remote repositories. We will refer to the checked out directory as <PROJECT> |
3 | Open a console, switch into the checked out folder and execute gradle_environment.bat. | This sets several environment variables, including SERVER inside this console. We will refer to this console as developer console. Keep using it through the remaining steps. |
4 | Create your gradle.properties file | Create the file <user profile>\.gradle\gradle.properties |
5 | Run | The enableHotCodeReloading task ensures that your locally built cartridges are monitored by the development server for changes. This also creates the file environment.properties.sample. It is a template for all deployment configuration required to deploy a server for development. Seesection environment.properties.sample |
6 | Copy <PROJECT> \<assembly name>\target\samples\environment.properties.sample to <PROJECT> \<assembly name> \environment.properties and fill in the gaps and make necessary adjustments. | At least adjust the following sections: |
7 | Go to <PROJECT> and run gradlew deployServer . | This builds your components and deploys the assembly as your test server into <SERVER> (= <PROJECT>\build\server). Note IS_HOME now resides at <SERVER>\local and IS_SHARE at <SERVER>\share. |
8 | Run as administrator with root privileges (as requested in the console output): <SERVER>\postInstall\installServices.bat | This creates the services. The services operate with your user privileges. You will be prompted for your password. |
9 | Go to <PROJECT> and run:
Note The command | See theRecipe: Initialize the Databasefor details. |
10 | At the developer console go to your Intershop Studio installation and run | It is important to start Intershop Studio from a developer console with all environment variables set. No more initial configuration in the preference menu is necessary. Using Gradle requires Intershop Studio version >= 4.3.4. Info You may run into a problem when opening the preference dialog the first time, see the boxIssue with Intershop Studio Preferencesbelow. |
11 | Import the Gradle multi project using the IStudio wizard Component Set projects into Workspace. | Seesection Intershop Studioon how to import a component set. |
* Commands provided by gradle_environment.bat
Starting services and the application server are out of scope of this document.
# | Action | Explanation |
---|---|---|
1 | Check if the minimum system requirements are fulfilled.
Additionally to the general requirements:
| By default, the gradle_environment.sh (see next step) expects the Intershop Studio executable to be installed at /opt/intershop/IntershopStudio/IntershopStudio. If your Intershop Studio is located elsewhere adapt the line defining openStudio in gradle_environment.sh accordingly. |
2 | Create an empty directory to contain your development environment. Check out the project from your VCS to the directory (as generated at <sources>/projects/<project name> inCookbook - Setup of CI Infrastructure). | The partition/drive should have enough space/speed to hold your sources, a deployed server and the size of a deployed server caches for remote repositories. We will refer to the checked out directory as <PROJECT>. |
3 | Open a console, switch into the checked out folder and execute: | This sets several environment variables, including SERVER inside this console. We will refer to this console as developer console. Keep using it through the remaining steps. |
4 | Create your gradle.properties file | Create the file <user profile>/.gradle/gradle.properties
|
5 | Run ./ | The This also creates the file environment.properties.sample. It is a template for all deployment configuration required to deploy a server for development. Seesection environment.properties.sample |
6 | Copy <PROJECT><assembly name>/target/samples /environment.properties.sample to <PROJECT>/<ASSEMBLY>/environment.properties and fill in the gaps and make necessary adjustments. | At least adjust the following sections: |
7 | Go to <PROJECT> and run ./gradlew deployServer . | This builds your components and deploys the assembly as your test server into <SERVER> (= <PROJECT>/build/server). Note IS_HOME now resides at <SERVER>/local and IS_SHARE at <SERVER>/share. |
8 | Run as administrator with root privileges (as requested in the console output): <SERVER>/postInstall/installServices.sh | This creates the init.d-scripts. The services will run with your user privileges. |
9 | Go to < PROJECT > and run:
Note The command | See theRecipe: Initialize the Databasefor details. |
10 | On the developer console go to your Intershop Studio installation and run (or run | It is important to start Intershop Studio from a developer console with all environment variables set. No more initial configuration in the preference menu is necessary. Using Gradle requires Intershop Studio version >= 4.3.4. Info You may run into a problem when opening the preference dialog the first time, see the boxIssue with Intershop Studio Preferencesbelow. |
11 | Import the Gradle multi-project using the IStudio wizard Component Set projects into Workspace. | See thesection Intershop Studioon how to import a component set. |
* Commands provided by gradle_environment.sh
Starting services and the application server are out of scope of this document.
The Gradle user home (<GRADLE_USER_HOME>) is located in its default location, usually <OS_USER_HOME>/.gradle
The project home contains an environment script (gradle_environment.bat | gradle_environment.sh), see next section. The project home is checked into the VCS.
When setting up your CI environment a script gradle_environment.bat | gradle_environment.sh is generated. This script configures the directory layout you work with, by setting a few environment variables.
We refer to a console with these environment variables in place as a developer console. Run all gradlew
commands and Intershop Studio from a developer console.
To start a developer console:
The following table lists the most important environment locations provided from gradle_environment.bat | gradle_environment.sh represented by environment variables.
Name | Contents | Environment variable |
---|---|---|
Project directory | VCS working copy of project sources | DEVELOPER_BASE |
Server directory | Server deployed for manual and automatic testing (contains both IS_HOME and IS_SHARE as sub-folders) | SERVER |
Intershop Studio workspace | Workspace data | WORKSPACE |
These environment variables are partly for your convenience and partly to configure Gradle/Intershop Studio.
The environment script provides the following alias commands:
Command | Function |
---|---|
cdServer | Change directory to server directory |
openStudio | Open Intershop Studio |
Running gradlew publish
in <PROJECT>
actually consists of of two steps, first build, then publish. It is necessary to not only build components, but also to publish them to a repository (e.g., copy them to a folder with predefined structure) for two reasons:
compile group: 'com.intershop', name: '<name>'
in a component's build.gradle file. They must be resolved from (a local or remote) repository.compile project(':<name>')
. (Project dependencies resolved directly from the target directories)The first call of gradlew in the project will generate a sample file for the deployment configuration. But this will only happen if:
<project name>BuildEnvironmentProperties
is specified or the file, specified for this property, does not existbuildEnvironmentProperties
is specified or the file, specified for this property, does not existIf no sample file is generated please check the location of the assembly project, the environment settings and (depending on the workflow) either the
for some of this configuration properties. Furthermore, there is a property buildEnvironmentPropertiesSample
, which defines the location of the sample file. If this property is not set, the sample file can be found in the default location:
<PROJECT>/<assembly name>/target/samples/environment.properties.sample
The developer deployment first generates a <SERVER>/settings.gradle file from the environment.properties configuration. Based on this file it then runs standard deployment procedure as described inConcept - Gradle Deployment Toolsspecifying the host type all
, e.g., deploying all host types of the assembly. As deployment source uses the repositories declared in your corporate plugin as well as your local repository at <REPO>.
Besides being based on the same deployment scripts, the developer deployment is also tailored for development in a few ways:
The properties IS_SOURCE
in <SERVER>/local/intershop.properties and cartridges.source
in <SERVER>/share/system/cartridges/cartridgelist.properties. This ensures that the application server uses the cartridges' checkout directory to load static artifacts and classes.
development
(i.e., that are not included in the production
environment), like the dev_lilith cartridge.Open debug ports in tomcat.bat | tomcat.sh and dbinit.bat | dbinit.sh as configured in <ASSEMBLY>/environment.properties.
The task enableHotCodeReloading
will add the following properties to the gradle.properties located in the GRADLE_USER_HOME:
sourceDirectories=<path to the project sources> sourceCartridges.<project name>=<components of your project>
These settings are necessary for the development environment to load changed files in the server direct from the sources. It is also necessary for other development settings, e.g., the debug port configuration.
The post-install scripts perform all deployment operations for which administrator / root privileges are required. Currently this is only the creation of services. The developer deployment uses the current user as deployment user and – on Windows – also as user for executing the deployed applications / services. Therefore, you have to enter your password for every service to be created.
After the post-install scripts, running services / applications is completely up to you and works mostly as before.
If starting any service fails on Windows, please refer to the Recipe (Windows) Starting a Service Fails in Cookbook - Deployment Tools, according to your ICM version:
Intershop Studio will find your sources, the deployed server etc. by relying on the environment variables in a developer console. Therefore, start Intershop Studio from a developer console. No more initial configuration in the preference menu is necessary.
To import your project into the workspace:
To import your assembly into the workspace, use the same steps, but instead select the import wizard Gradle | Gradle Project. I.e:
Note
Issue in Intershop Studio Preferences
There is a known issue in Intershop Studio 4.3.4:
When accessing the preference dialog (menu Window | Preferences) and the preference page Intershop Studio there may be a red cross next to Development Gradle Properties. When hovering over this cross, a text similar to the following will be displayed: The key 'serverDirectory' is not found in the properties file. Also in this case you cannot select another preference page on the right nor close the dialog with the OK button.
Make sure that you started Intershop Studio from a developer console with all environment variables set.
If you did so and the problem still occurs, you may have run into the issue ISTUDIO-123. The issue is fixed in higher versions. For a workaround in the meantime, please see the steps below the picture.
This problem is mostly cosmetic and will not affect you in your work. (Intershop Studio will find serverDirectory
using environment variables set by the gradle_environment.bat | gradle_environment.sh.)
To be able to work with the preference dialog again, use the following workaround:
The preference page General will be selected and you can continue working.
Avoid selecting the preference page Intershop Studio. (If you select it, you will have to repeat the workaround.) It is not necessary to configure anything there.
Preference pages nested under Intershop Studio are not affected and can and should still be used.
The following diagram shows how data flows between directories (blue) during the different steps (red).
Note
The application server can now read (denoted by dotted lines) static artifacts like ISML templates, pipelines, queries etc directly from the SVN working copies. No more linking / copying is necessary. Also it reads classes directly from the target directories.
Gradle tasks are the units of work you can trigger. This recipe describes how. For an introduction beyond this recipe, please refer to the Gradle user guide.
You may run Gradle tasks using Intershop Studio or the console. Generally you have to:
The assembly, all cartridges and the multi project itself are Gradle projects. Components and assembly are sub projects of one multi project.
Tasks can have dependencies to other tasks. Executing a certain task will always also execute its dependencies.
You may specify multiple tasks to run in one execution of Gradle. The order of depending tasks is mostly determined automatically by Gradle.
Tasks independent of each other are executed in the order in which you are passing in the tasks.
Note
Be aware that the order of independent tasks is important. E.g., executing a cleaning task after the build task leads to an empty directory.
In Intershop Studio each Gradle project is represented by an Eclipse project.
To execute tasks in a cartridge/assembly or in the root project:
You may also specify additional parameters in the dialog.
To reuse and switch between multiple configurations per project (e.g., different deploy or database tasks in the assembly), give them different names. Thus they can be found in the list of the external tool configurations.
To execute tasks via Console:
gradlew :<task1> :<task2>
, e.g., gradlew :deployServer :importDump
./gradlew :<task1> :<task2>
, e.g., ./gradlew :deployServer :importDump
Syntax difference on Linux
In the remainder of this section we will ignore the minor difference between execution on Linux and Windows. Always run ./gradlew
instead of gradlew
if you work on Linux.
To execute a task in a certain cartridge (i.e., a child-project), pass in :<cartridge>:<task>
, e.g., gradlew :core:clean :core:build
.
You can also combine tasks from different cartridges, e.g., gradlew :core:build :bc_foundation:build
.
Tasks names with or without colon
To execute a task in all cartridges of the project execute gradlew <task>
(without colon), e.g., gradlew build
. Running the command with a colon, e.g., gradlew :build
, leads to an error if the task does only exist for sub projects, but not for the root project:
FAILURE: Could not determine which tasks to execute. * What went wrong: Task 'build' not found in root project 'projectName'. * Try: Run gradlew tasks to get a list of available tasks.
If you start remote tests for the assembly the server will be not stopped or started.
For most tasks during development of remote tests it is necessary to have a running server. The situation on a CI server is different. Before a remote test can run, it is necessary to start the server. Regardless of the remote test result it is required to stop the server.
If you want run remote tests on your development machine it is necessary to exclude some stop tasks:
gradlew -x stopNodemanager -x stopWebserver remoteTest
The following section is a loose collection of helpful hints to get you started with Gradle. Run all of them in a developer console.
To display all sub projects in the Gradle multi-project execute the following inside <PROJECT>:
gradlew :projects
To display tasks of a (root) project:
gradlew :tasks
To display the tasks of a certain sub-project (e.g., cartridge, assembly) run:
gradlew :<name>:tasks
To find out which tasks are actually going to be executed (e.g., which dependencies are automatically pulled in) and in which order:
gradlew <tasks> --dry-run
Note
The installation of the Oracle database software and database instance especially a XE instance is not part of the Intershop deployment tools, but is performed by the Oracle setup routine. The Guide - Setup Oracle XE as Intershop Development Database (valid to 7.10)describes, how the Oracle XE edition as well as Intershop 7 need to be configured for use as development database.
The database must be initialized before testing (or as part of the test, i.e., to see if the database can be initialized).
There are two ways to initialize your database.
You may import the database dump generated for the released version of your assembly. This is only useful if your local changes have no effect on the initial database state. To import the dump run the task importDump
on the assembly.
The release version from which the dump is taken is determined by the property dump.<assembly organization>.<assembly name>
in <GRADLE_USER_HOME>/gradle.properties. This way re-running the importDump
task always imports the same dump, unless you change the property.
The dump property is automatically created upon first run of the importDump
task. To update the property to the latest released version run the updateDumpVersion
task.
You may run the DBInit through assembly. To do so:
gradlew dbinit -PskipDeployment
./
gradlew dbinit -PskipDeployment
Note
The command gradlew dbinit
does not work for an MSSQL database, but only for Oracle (since it will always import the dump first, which is an Oracle dump) . Only classic manual DBINIT will work for MSSQL database setups.
The task dbinit
has a dependency to deployServer
, i.e., if you execute the DBInit the server is automatically be deployed before that. If you want to run dbinit
without prior execution of deployServer
, pass in -PskipDeployment
.
The dump is downloaded from the release repository and handed over to ant import
at <SERVER>/local/tools/misc.
Also branding installations, which are usually created by running DBInit are downloaded from the release repository and extracted into <SERVER>/share/sites.
You can still use ant import
at <SERVER>/local/tools/misc to import other dumps.
Quick Start
The Intershop delivery/DVD comes with two dumps that might be useful until your own assembly was built by a CI server.
Find them in the delivery/on the DVD at:
You can also find them in a repository (like a Nexus) filled with the delivery contents in a similar path.
To use them:
ant import
.The command first executes ant dbschema-clean
at <SERVER>/local/tools/misc to purge your database account. After that it executes dbinit --classic
in <SERVER>/local/bin, i.e., a full DBInit over all cartridges without interactions.
You may still run these commands manually if you like - or need to pass in other options.
After the initial setup, the developer changes the sources of the project. This may happen because of changes made by the present developer or updates to the VCS working copies of a project. The developer must be able to see these changes in the deployed server.
Depending on the kind of change, different actions are necessary to make the changes visible in the running server.
Kind of change | Action |
---|---|
The changed code artifact resides in <PROJECT>/<cartridge>/staticfiles/cartridge. | Reload the page. The application server automatically reloads the files directly from this directory (and recompile ISML templates if necessary). |
The changed code artifact is a Java class. | Rebuild the affected cartridges and restart the application server. The application server loads the classes from <PROJECT>/<cartridge>/target/classes. |
The changed code artifact resides in <PROJECT>/<cartridge>/staticfiles/share. | Publish and redeploy the affected cartridge(s) and restart the application server / re-run the dbinit. (Publishing automatically includes rebuilding.) |
You are unsure which kinds of changes have been made, e.g., you updated your VCS working copy. | Redeploy the components. You may also want to reinitialize your database, seeRecipe: Initialize the Database. |
Changes in the assembly, including changes in <PROJECT>/<ASSEMBLY>/environment.properties. | Redeploy the whole assembly. You may also want to reinitialize your database, seeRecipe: Initialize the Database. |
See discussion below for how to perform these actions.
Please, refer to theRecipe: Run Gradle Taskson how to run these tasks. This recipe also mentions how to execute a task on multiple or all cartridges at once.
To rebuild (e.g., recompile) a cartridge, run the build
task on that cartridge.
The buildDependents
task builds the cartridge itself and all cartridges in your project that depend on it. This is useful to see if Java changes cause compilation errors in depending components.
If not cleaning the build results before building / publishing, Gradle performs an incremental build. Gradle only re-executes Gradle tasks whose inputs have changed (or whose outputs have been tampered with). This is somewhat safer and more reliable than re-executing an Ant build. Using the non-cleaning, incremental build should suffice for developers most of the time.
To execute a clean build run the tasks clean
and build
on the cartridge(s).
Using these tasks does not touch the contents of your local repository. If you later redeploy your changes, make sure to publish them before.
To republish a cartridge to your local repository, run the publish
task on that cartridge. This overwrites the local version of that cartridge inside your local repository at <REPO>.
All deployment tasks are run on the assembly project. Before you can deploy any change, you must have published it.
To redeploy all cartridges of your project run the task deployCartridges
.
To redeploy only a few cartridges:
<ASSEMBLY>
gradlew deployCartridges -Pcartridges="<space separated list of cartridges>"
, e.g., gradlew deployCartridges -Pcartridges="core bc_foundation"
./gradlew deployCartridges -Pcartridges="<space separated list of cartridges>"
, e.g., ./gradlew deployCartridges -Pcartridges="core bc_foundation"
To redeploy the whole server run the task deployServer
.
Note
The deployment also works incrementally and touches only files that have been changed (it does not delete all files). In most cases, it should be possible to keep services / the application server running. Restart after the deployment, if the application server only reloads the changed files upon restart (like for most Java classes).
Running the post-install scripts again is not necessary after redeployment.
A developer needs to execute and debug tests.
There are currently three ways to execute tests.
This should be the preferred way to execute tests for the developer.
Before being able to run the system or integration tests, you must set up your IStudio workspace:
To run or debug a single test:
To run multiple tests that are not in the same Java package, please create a JUnit4 test suite first and run that suite.
This way of execution applies to all types of tests.
You may run all unit tests of a cartridge (i.e., not a _test-cartridge) by running the Gradle test
task on that cartridge. A report is generated per cartridge at <PROJECT>/<cartridge>/target/reports/tests/index.html.
You may also run the Gradle test
task on the project. This executes the test
tasks of all cartridges and assembly. If your project uses the old project structure with separate component set and assembly projects, the assigned plugin com.intershop.build.gradle.plugins.ComponentSetPlugin (component-set) will generate an overall report of all cartridge tests. The report is then located under <PROJECT>/target/reports/allTests/index.html.
Note
This approach only executes unit tests!
You may run multiple integration tests or system tests with the Intershop Test-Runner:
ES<n>|...
(e.g., ES1|D:\is7\trunk\
), run <SERVER>/local/bin/environment.bat.ant test
.Unit tests are not available in the test runner anymore! See the discussion below for rationale.
There are three kinds of tests that are treated differently.
Unit tests are tests that require nothing but a properly populated class path to run. Especially, they cannot require a pre-created files or directories (like through deployment) or a database. (They may however start up a pretty complete server in their initialization - as long as this server does not access any file system resources, like configuration files.)
Super classes/annotations for Unit tests are:
junit.framework.TestCase
(legacy test cases written for JUnit version <= 4)@RunWith
annotation (newly written test cases starting with JUnit 4)Unit tests are located in the same cartridge as the functionality they test.
Run unit tests using:
Unit tests are not deployed
Unit tests are solely for execution by the developer and during build by the continuous integration server. Since unit tests are not needed after the build process any longer, they are not packaged up and cannot be deployed.
As a consequence of this simplification they are not available for execution in the test runner any more.
Integration tests require a fully deployed server and are executed within that server, so they have direct access to the classes and objects in the JVM.
Super classes for Integration tests are:
com.intershop.tools.etest.server.UnitTestCase
(sic!)com.intershop.tools.etest.remote.CAPITestCase
Integration tests are located in the accompanying test cartridge of the cartridge being tested (bc_pricing_test for bc_pricing).
Run integration tests using:
System tests run outside the server and access it via any remote interface (e.g., via HTTP). Technically they are run like unit tests, but they require additional Java properties to know how to connect to a server.
Run integration tests using:
Developers need to add new cartridges to an existing multi project.
To add a new cartridge to an existing project perform the following overall steps:
Please see discussion below for details on how to perform these steps.
It is not necessary to register the cartridge inside the multi-project in any way. Instead all sub-folders not explicitly excluded in <PROJECT>/settings.gradle are treated as components and included in the build. This way upon commit they are also included in the build of the continuous integration server automatically.
Other non-Gradle related steps, like adding the cartridge to an application type may still be necessary.
Note
Unique cartridge names
Besides publishing cartridges with a qualified name, e.g., with an organization and a name, for legacy reasons the unqualified names still have to be unique. I.e., you cannot create a cartridge with the organization com.customer
and name core
, because there already is core
in com.intershop
. Instead keep adding prefixes to the name like customer_core.
The build.gradle file of a cartridge is both, the build script and the build configuration file for that cartridge. Reusable build functionality comes in Gradle build plugins. Different kinds of artifacts are handled by different plugins. The Gradle build will fail, if you apply a plugin, but there are no matching source files to process.
Intershop Studio generates an initial build.gradle file that is suitable for cartridges containing Java source code and static files. Please refer toCookbook - Gradle Build Tools | Configure the Build of a Component / Cartridgeon how to configure your build.gradle file.
Note
Cartridges that contain ISML templates must declare a few dependencies:
dependencies {
compile group:
'com.intershop'
, name:
'tools'
compile group:
'com.intershop'
, name:
'isml'
compile group:
'com.intershop'
, name:
'servletengine'
compile group:
'com.intershop'
, name:
'core'
}
... Execution failed for task ':<cartridge>:isml2classMain' > taskdef class com.intershop.beehive.isml.capi.ISML2JSP cannot be found using the classloader AntClassLoader ....
When declaring dependencies you need to distinguish between:
compile project(':<cartridge name>')
inside the dependencies block.compile group: '<cartridge organization>', name: '<cartridge name>'
The following example demonstrates the different declarations.
dependencies { compile group: 'com.intershop', name: 'tools' compile project(':customer_base') }
As already used from dependency management with Ivy, the compile classpath is resolved intransitively: If you specify a dependency to the core cartridge you will not automatically have a dependency to tools. So you will not have tools in your classpath unless you declare the dependency explicitly.
No versions in build.gradle file
External dependencies do not have to declare versions directly. Instead Intershop recommends to declare them using version and filter properties in a gradle.properties file. SeeConcept - Gradle Build Tools | Configuring Dependency Versionsfor details.
Please follow the Recipe inCookbook - Gradle Assembly Tools | Add Cartridges to an Assembly.
To let the changes take effect locally, redeploy your assembly, as described inRecipe: Make Changes Effective on the Server.
The developer needs to remove the development environment when finished to free system resources.
undeploy
on the project. This first execution generates an uninstall script for the services.undeploy
on the project again. This purges your server directory.The Gradle cache located <GRADLE_USER_HOME>/cache currently grows indefinitely and may eventually fill the hard disk.
On Windows:
gradlew --stop
.On Linux:
./gradlew --stop
.The Gradle cache contains:
Gradle has no feature for selectively cleaning the artifact cache so far: http://forums.gradle.org/gradle/topics/managing_artifact_cache_growth.
In the meantime, you have to revert to completely deleting the Gradle cache occasionally as described above. The disadvantage of this approach is that all artifacts required for further build and deployment processes will be downloaded again.
Before deleting the cache directory all processes that hold file handles into it must be stopped, i.e., all Gradle daemons. You can do so by calling gradlew --stop
.
You can see all running Gradle daemons (not just of the current Gradle user home) by running jps
. Example of output:
19452 lilith.jar 22244 Jps 17448 GradleDaemon 13520 15852 GradleDaemon 16772 3468 GradleDaemon 22276