This article will cover setting up a development environment to create custom strategies and modules for the Marketcetera platform. The instructions will use Eclipse as an example, but you can use a different IDE if you wish.
To start, install the Strategy Engine. After installation, here's what you have:
$ tree -d strategyengine strategyengine ├── bin ├── conf │ └── sa ├── lib ├── logs ├── modules │ ├── conf │ └── jars ├── samples │ ├── commands │ ├── java │ │ ├── inputs │ │ └── scripts │ └── ruby │ ├── inputs │ └── scripts └── src 17 directories
For our build environment, in addition to the IDE of your choice, you'll also need Maven and a Java JDK installed. For 3.x, Marketcetera requires a minimum of Java 7.
The first step is to modify the directory structure above to prepare it for Maven. Here's a sample pom.xml file you can use to build your Maven project.
Install this pom file in the strategyengine
directory.
Next, modify the src
directory to match the structure that Maven will expect.
$ cd strategyengine $ mkdir -p src/main/java src/main/resources $ tree -d . ├── bin ├── conf │ └── sa ├── lib ├── logs ├── modules │ ├── conf │ └── jars ├── samples │ ├── commands │ ├── java │ │ ├── inputs │ │ └── scripts │ └── ruby │ ├── inputs │ └── scripts └── src └── main ├── java └── resources 20 directories
Create a project for Eclipse to find.
$ mvn install eclipse:eclipse [INFO] Scanning for projects... ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.138 s [INFO] Finished at: 2017-10-17T08:34:31-07:00 [INFO] Final Memory: 34M/512M [INFO] ------------------------------------------------------------------------ $ tree -d . ├── bin ├── conf │ └── sa ├── lib ├── logs ├── modules │ ├── conf │ └── jars ├── samples │ ├── commands │ ├── java │ │ ├── inputs │ │ └── scripts │ └── ruby │ ├── inputs │ └── scripts ├── src │ └── main │ ├── java │ └── resources ├── target │ ├── classes │ └── maven-archiver └── target-eclipse └── classes 25 directories
Open Eclipse and select /opt/Marketcetera-3.0.12
(or your installation directory) as the workspace.
Import existing projects to pick up the strategyengine
project you created above with Maven.
Choose the strategyengine
directory.
The development environment is now ready. You can create your classes in the src/main/java
directory and build them. In order for the Strategy Engine to use the classes you create, copy the resulting JAR file to modules/jars
. It is possible to configure the Maven pom.xml
to deploy the JAR to modules/jars
automatically, but it is preferable to keep this as a manual step to make sure you deploy artifacts that you are certain are ready to go.
$ ls target classes maven-archiver strategy-1.0.0-SNAPSHOT.jar strategy-1.0.0-SNAPSHOT-tests.jar $ cp target/strategy-1.0.0-SNAPSHOT.jar modules/jars/
The JAR file is now available to the Strategy Engine for use. See Creating a New Strategy for instructions on how to build strategies.
1 Comment
Unknown User (paulh1)
Maven project wasn't building in Eclipse for Windows due “Plugin execution not covered by lifecycle configuration”
Here a quick fix:
Window > Preferences > Maven > Errors/Warnings > Plugin execution not covered by lifecycle configuration. Select Ignore or Warning
it doesn't modify your pom.xml.
Then you will need to do a Maven > Update project