Setting up Developer Environment
Prerequisites
- Install Development Tools.
- Clone the
ep-commerce
Git repository. For more information, see Source Code.
Configuring Environment Variables
Use this procedure to set system environment variables for:
- Java:
JAVA_HOME
andJAVA_OPTS
- Maven:
MAVEN_HOME
andMAVEN_OPTS
Windows
Open the Start menu, right-click My Computer and select Properties.
Click Advanced System Settings.
To quickly show the System Properties > Advanced > Environment Variables from the Windows Run prompt, type
SystemPropertiesAdvanced
and press Enter.In the System Properties > Advanced, click Environment Variables.
To add a new system environment variable, on the Environment Variables window, click New.
Add the following:
JAVA_HOME
:C:\Program Files\Zulu\zulu-8-amd64
JAVA_OPTS
:-Xmx1024m -Dsun.lang.ClassLoader.allowArraySyntax=true
MAVEN_HOME
:C:\apache-maven-3.6.2
MAVEN_OPTS
:-Xmx2548m -XX:ReservedCodeCacheSize=128m -Dsun.lang.ClassLoader.allowArraySyntax=true
The values for the
JAVA_HOME
andMAVEN_HOME
variables depend on the location where Java and Maven are installed. This location might differ from the default values provided.Select the
Path
system variable, and click Edit.Add the following variables at the end of the
Path
variable:;%JAVA_HOME%\bin;%MAVEN_HOME%\bin;
Mac and Linux
Modify your
~\.bash_profile
(if using Bash shell) or~\.zshrc
(if using zsh shell) in your home folder to set the required environment variables.export JAVA_HOME=$(/usr/libexec/java_home -v "1.8.0") export JAVA_OPTS="-Xmx1024m -Dsun.lang.ClassLoader.allowArraySyntax=true" export MAVEN_HOME=/home/USERNAME/tools/apache-maven-3.6.2 export MAVEN_OPTS="-Xmx2548m -XX:ReservedCodeCacheSize=128m -Dsun.lang.ClassLoader.allowArraySyntax=true" export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
Open a new terminal window and verify the installation as follows:
$ java -version openjdk version "1.8.0_275" OpenJDK Runtime Environment (Zulu 8.50.0.51-CA-macosx) (build 1.8.0_275-b01) OpenJDK 64-Bit Server VM (Zulu 8.50.0.51-CA-macosx) (build 25.275-b01, mixed mode) $ mvn -version Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T08:06:16-07:00) Maven home: /Users/gdenning/apache-maven-3.6.2 Java version: 1.8.0_275, vendor: Azul Systems, Inc., runtime: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre Default locale: en_CA, platform encoding: UTF-8 OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"
settings.xml
Configure Maven With a Maven Repository Manager
A Maven repository manager is required for effective shared development. If your team has prepared the Maven repository manager then complete the below instructions to configure your settings.xml
to use it. For more information about configuring a Maven repository manager, see Maven Repository Manager.
Before you build the source code, create a local Maven directory and update the settings.xml
file.
Create an
.m2
directory in your local user home directory. Example:mkdir ~\.m2
Copy the
settings.xml
file from theextensions/maven
folder of theep-commerce
source code to your~/.m2
folder.Edit the following values in the
settings.xml
file to match your local developer environment.Setting Description epdb.reset_user
Maven Profile: mysql-dev-db
. The database account with administrative permissions that can drop and create databases and users in your local database.epdb.reset_password
Maven Profile: mysql-dev-db
. The password forepdb.reset_user
.ep.local.asset.path
The path to your local extensions/assets/ext-assets/src/main/assets
source directory.ep.smtp.host
The host name of your SMTP Server. internet-mirror
The URL of your organization’s Nexus server. Verify that the URL is already set. If not, contact the person who set up the team environment. For more information, see Update Maven Settings. warning
If these property values do not exist in the
settings.xml
file then you may have issues locally building and deploying the Elastic Path Commerce Web Applications.
Without A Maven Repository Manager
If your team has not yet prepared the Maven repository manager then complete the below instructions to configure your settings.xml
to define the repositories locally. For more information about configuring a Maven repository manager see Maven Repository Manager.
The extensions
module in Elastic Path Commerce source contains a maven/individual-settings.xml
that you can use if your Maven repository manager is not yet ready.
Copy
individual-settings.xml
to${user.home}/.m2
and rename it tosettings.xml
.Change
EP_REPOSITORY_USER
andEP_REPOSITORY_PASSWORD
to the credentials used for connecting to the public Elastic Path Maven repository.<servers> <server> <id>ep-public</id> <username>EP_REPOSITORY_USER</username> <password>EP_REPOSITORY_PASSWORD</password> </server> <server> <id>ep-cortex</id> <username>EP_REPOSITORY_USER</username> <password>EP_REPOSITORY_PASSWORD</password> </server> <server> <id>ep-commerce-engine</id> <username>EP_REPOSITORY_USER</username> <password>EP_REPOSITORY_PASSWORD</password> </server> <server> <id>ep-accelerators</id> <username>EP_REPOSITORY_USER</username> <password>EP_REPOSITORY_PASSWORD</password> </server> </servers>
Make any changes required for your project environment.
Local Database Setup
Elastic Path Commerce supports multiple database engines. Depending on which engine you choose, you will want to setup the corresponding database on your local development environment. Follow the steps in the appropriate section below.
MySQL
In a command prompt, run the shell command below to download and run the MySQL Docker image.
For MySQL 5.7:
docker run --name mysql-57-db --env="MYSQL_ROOT_PASSWORD=mysecretpassword" -p 3306:3306 -d mysql:5.7 --transaction_isolation=READ-COMMITTED --lower_case_table_names=1
For MySQL 8.0:
docker run --name mysql-80-db --env="MYSQL_ROOT_PASSWORD=mysecretpassword" -p 3306:3306 -d mysql:8.0 --transaction_isolation=READ-COMMITTED --lower_case_table_names=1
note
It is recommended to change
mysecretpassword
to something more secure.Edit your
~/.m2/settings.xml
:- In the
<activeProfiles>
section uncommentmysql-dev-db
and comment out all other profiles ending with-dev-db
. - Check the
mysql-dev-db
profile definition and ensure thatepdb.reset_password
is set to the password you defined when starting the Docker image.
- In the
Browse to your Elastic Path Commerce repo, open folder
extensions/database
and run the following command:mvn clean install -Preset-db
.
Oracle
If you are running on an M1 or M2 Macbook, follow the Install Oracle (M1/M2 Mac only) instructions. For all other operating systems, follow the Install Oracle (Non-M1/M2 Mac and Windows) instructions.
Install Oracle (M1/M2 Mac only)
-
brew install lima
Create a new
Ubuntu Virtual Machine
:limactl start
A menu will appear. Select
Open an editor to review or modify the current configuration
. Using the editor, modify the following properties:arch: "x86_64" memory: "8GiB"
Save the file and exit the editor. Several files will be downloaded and installed.
note
If you run into a bug where Lima gets stuck on
Waiting for the essential requirement 1 of 5: "ssh"
for several minutes and then fails, follow these steps.Connect to the Lima VM console.
lima
In a command prompt, run the shell commands below to login, download, and run the Docker image. Replace
<email>
and<password>
with your Oracle credentials. Also feel free to change the Oracle database password specified inORACLE_PWD
.nerdctl login -u <email> -p <password> container-registry.oracle.com nerdctl run -d --name oracle-19-db -p 1521:1521 -e ORACLE_PWD=mysecretpassword container-registry.oracle.com/database/enterprise:19.3.0.0
Ensure that Oracle is running on Docker using
nerdctl ps -a
. You should see a container namedoracle-19-db
.The container may take several hours to start the first time. Monitor progress by viewing the Docker logs. Run
nerdctl logs -f oracle-19-db
. When the logs showDATABASE IS READY TO USE!
, Oracle is started.Open a terminal window to the Docker container.
nerdctl exec -it oracle-19-db bash
Follow the steps in Set max_string_size to extended.
Install Oracle (Non-M1/M2 Mac and Windows)
Ensure that Docker is installed and running on your local machine.
In a command prompt, run the shell commands below to login, download, and run the Docker image. Replace
<email>
and<password>
with your Oracle credentials. Also feel free to change the Oracle database password specified inORACLE_PWD
.docker login -u <email> -p <password> container-registry.oracle.com docker run -d --name oracle-19-db -p 1521:1521 -e ORACLE_PWD=mysecretpassword container-registry.oracle.com/database/enterprise:19.3.0.0
Ensure that Oracle is running on Docker using
docker ps -a
. You should see a container namedoracle-19-db
.The container may take several hours to start the first time. Monitor progress by viewing the Docker logs. Run
docker logs -f oracle-19-db
. When the logs showDATABASE IS READY TO USE!
, Oracle is started.Open a terminal window to the Docker container.
docker exec -it oracle-19-db bash
Follow the steps in Set max_string_size to extended.
Set Max String Size to Extended
In the terminal window, run the following commands:
export ORACLE_SID=ORCLCDB sqlplus sys/mysecretpassword as sysdba
Within
sqlplus
, run the following commands to start theEXTENDED
mode upgrade:ALTER SESSION SET CONTAINER=CDB$ROOT; ALTER SYSTEM SET max_string_size=extended SCOPE=SPFILE; SHUTDOWN IMMEDIATE STARTUP UPGRADE quit
In the terminal, run the following commands to finish the
EXTENDED
mode upgrade for the containerized databases:cd $ORACLE_HOME/rdbms/admin $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS --force_pdb_mode 'UPGRADE' -d $ORACLE_HOME/rdbms/admin -b utl32k_cdb_pdbs_output utl32k.sql sqlplus sys/mysecretpassword as sysdba
Within
sqlplus
, run the following commands to restart the database:SHUTDOWN IMMEDIATE STARTUP quit
Run the following commands to finish the
EXTENDED
mode upgrade for the main database:cd $ORACLE_HOME/rdbms/admin $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS --force_pdb_mode 'READ WRITE' -d $ORACLE_HOME/rdbms/admin -b utlrp_cdb_pdbs_output utlrp.sql
Exit the Docker container.
exit
Follow the steps in Create ep-commerce schema.
Create ep-commerce schema
Modify the
oracle-dev-db
profile in your Mavensettings.xml
as specified below.<profile> <id>oracle-dev-db</id> <properties> <epdb.host>localhost</epdb.host> <epdb.port>1521</epdb.port> <epdb.databasename>ORCLPDB1</epdb.databasename> <epdb.username>C##COMMERCEDB</epdb.username> <epdb.password>ep</epdb.password> <epdb.reset_databasename>ORCLCDB</epdb.reset_databasename> <epdb.reset_user>sys as sysdba</epdb.reset_user> <epdb.reset_password>mysecretpassword</epdb.reset_password> <epdb.default.tablespace>USERS</epdb.default.tablespace> <epdb.temporary.tablespace>TEMP</epdb.temporary.tablespace> </properties> </profile>
Edit your
~/.m2/settings.xml
:- In the
<activeProfiles>
section uncommentoracle-dev-db
and comment out all other profiles ending with-dev-db
. - Check the
oracle-dev-db
profile definition and ensureepdb.reset_password
is set to the password you defined when starting the Docker image.
- In the
Browse to your Elastic Path Commerce repo, open folder
extensions/database
and run the following command:mvn install -Preset-db
.(Optional) Download and install SQLDeveloper.
(Optional) Use following default credentials to connect to your Oracle database from SQL Developer:
Username
:C##COMMERCEDB
Password
:ep
Hostname
:localhost
Port
:1521
Service name
:ORCLPDB1
Stop Lima (M1/M2 Mac Only)
Follow these steps to safely shut down Lima.
Connect to the Lima VM console.
lima
Stop Docker.
nerdctl stop oracle-19-db
Exit the Lima VM console.
exit
Stop the Lima VM.
limactl stop
Start Lima (M1/M2 Mac Only)
Follow these steps to start Lima again after you've completed the setup steps and previously stopped Lima.
Start the Lima VM.
limactl start
Connect to the Lima VM console.
lima
Start the Oracle Docker image.
nerdctl start oracle-19-db
The container should start within a couple of minutes. Monitor progress by viewing the Docker logs. Run
nerdctl logs -f oracle-19-db
. When the logs showDATABASE IS READY TO USE!
, Oracle is started.Exit the Lima VM console.
exit
PostgreSQL
A PostgreSQL database server can contain one or more named databases. Each database can contain one or more named schemas, which in turn contain tables. The Data Population tool will initialize a schema, but a database needs to be manually created first, using the instructions below.
In a command prompt, run the shell command below to download and run the PostgreSQL Docker image.
docker run --name postgresql-14-db --env="POSTGRES_PASSWORD=mysecretpassword" -p 5432:5432 -d postgres:14 -c max_connections=1000
note
It is recommended to change
mysecretpassword
to something more secure.Download and install pgAdmin.
Use following default credentials to connect to your PostgreSQL database from pgAdmin:
Username
:postgres
Password
: The password you defined when starting the Docker image.Hostname
:localhost
Port
:5432
Create a new database with name
COMMERCEDB
.Edit your
~/.m2/settings.xml
:In the
<activeProfiles>
section uncommentpostgresql-dev-db
and comment out all other profiles ending with-dev-db
.Check the
postgresql-dev-db
profile definition and ensure thatepdb.reset_user
is set topostgres
andepdb.reset_password
is set to the password you defined when starting the Docker image.epdb.schemaname
is set to public by default. This can be changed to any other value.note
PostgreSQL converts schema name string to lowercase regardless of the value specified.
Browse to your Elastic Path Commerce repo, open folder
extensions/database
and run the following command:mvn clean install -Preset-db
.