Development environment guide with Intellij and Kubernetes


#1

Please follow these steps in case you want to setup your development environment using IntelliJ and Kubernetes
Let us know in case you need additional help.

1. Get and install IntelliJ

Download the installer from https://www.jetbrains.com/idea/download/ .
Note: This guide is for the ultimate edition but with some exceptions it might work with the community edition as well.
The ultimate edition has some additional features for web application. E.g: autodetects spring and JEE applications and docker configurations , you can setup data sources for databases, and is also helpful for javascript.

2. Install Lombok

Please go to https://projectlombok.org/setup/intellij and install lombok

Edit your maven settings.xml file

Set up settings.xml from
http://docs.metasfresh.org/developers_collection/en/getting_started_maven_settings

You can copy the file to .m2 folder or any other place but make sure it’s set as it should be in
File->Settings

3. Clone and import the code

Go to VCS->Git->Clone and clone the following repos into a parent directory:

4. Build

All pom files will be detected, so you can clean install whatever is needed

5. Start metasfresh

All spring boot configurations will be detected so you will see the following:

  • Please make sure you use -Xmx4096M VM option before running.

  • Optional: If you want to use kubernetes and use windows , install “docker for desktop” from
    https://hub.docker.com/editions/community/docker-ce-desktop-windows

  • make sure kubernetes is enabled in the settings

  • go to metasfresh-dist->dist->src->main->kubernetes->manifests->dev

  • create the services and deployments described in the yaml files. Check
    https://kubernetes.io/docs/reference/kubectl/cheatsheet/ for help

  • After everything is deployed with kubernetes, copy the application.properties files from
    “metasfresh-dev” into the structures and run “WebRestApiApplication from IntelliJ

  • Check http://localhost:30080/ for the metasfresh UI

  • Optional: There are some eclipse launcher files in the project. You could install eclipser and
    convert the files. After installing and restarting you can right click on a “.launch” file and you’ll
    find the “convert with eclipser” option.

6.Eclipse to IntelliJ hints

  • In general A workspace in eclipse is a project in intelliJ and a project in eclipse is a module in intelliJ

  • You can import eclipse shortcuts into Intellij. Go to File->Settings->KeyMap

  • Import eclipse formatting. Go to File->Settings->Editor->Code Style and after clicking the scheme settings drop down you can import a file. Go the metasfresh-dev->eclipse-config->eclipse-metas-formatter.xml


#2

Just a week and will test this for myself :blush:


#3

I just saw a message where intelliJ recommended me to enable annotation processing and guided me to this setting:

@Hanelore I now activated it…did that make sense?
I’m not yet sure which parts of the compiling are really done by “native” maven (I guess there, the lombok related processing is on as per pom.xml) and where a setting like this one makes a difference (Note: I didn’t yet get to try and run anything from IntelliJ)


#4

Hi everyone, I am a newbie to metasfresh/java and spring boot framework, but I am most interested in this project and want to learn from it.

If someone could just clarify editing the settings.xml file to get the source code into Intelij ultimate I would be grateful.

Thus far using a Kubuntu 18.04 machine I have navigated using Dolphin from root/home/len/ than used control tab to unhide folders and files in my home dir. The path to the .xml file is Home/.m2/wrapper/dists/apache-maven-3.6.0-bin/2dakv70gp803gtm5ve1ufmvttn/apache-maven-3.6.0/conf/settings.xml

This is what the file looks like-

<!–
pluginGroup
| Specifies a further group identifier to use for plugin lookup.
com.your.plugins

–><!–
proxy
| Specification for one proxy, to be used in connecting to the network.
|

optional
true
http
proxyuser
proxypass
proxy.host.net
80
local.net|some.host.com

–><!–
server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the ‘id’ attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|

deploymentRepo
repouser
repopwd

–><!–
Another sample, using keys to authenticate.

siteServer
/path/to/private/key
optional; leave empty if not used.

–><!–
mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|

mirrorId
repositoryId
Human Readable Name for this Mirror.
http://my.repository.com/repo/path

–><!–
profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as ‘env-dev’, ‘env-test’, ‘env-production’, ‘user-jdcasey’, ‘user-brett’, etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id’s for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.

jdk-1.4

  <activation>
    <jdk>1.4</jdk>
  </activation>

  <repositories>
    <repository>
      <id>jdk14</id>
      <name>Repository for JDK 1.4 builds</name>
      <url>http://www.myhost.com/maven/jdk14</url>
      <layout>default</layout>
      <snapshotPolicy>always</snapshotPolicy>
    </repository>
  </repositories>
</profile>

–><!–

 | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
 | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
 | might hypothetically look like:
 |
 | ...
 | <plugin>
 |   <groupId>org.myco.myplugins</groupId>
 |   <artifactId>myplugin</artifactId>
 |
 |   <configuration>
 |     <tomcatLocation>${tomcatPath}</tomcatLocation>
 |   </configuration>
 | </plugin>
 | ...
 |
 | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
 |       anything, you could just leave off the <value/> inside the activation-property.
 |
<profile>
  <id>env-dev</id>

  <activation>
    <property>
      <name>target-env</name>
      <value>dev</value>
    </property>
  </activation>

  <properties>
    <tomcatPath>/path/to/tomcat/instance</tomcatPath>
  </properties>
</profile>

–><!–
activeProfiles
| List of profiles that are active for all builds.
|

alwaysActiveProfile
anotherAlwaysActiveProfile

–>

Am I to copy/edit in the additional code provided for the Intelij IDE above the last of the code in this file --> above??? and thank you for your assistance in advance.


#5

Hello,
I’m Cristian and I’m new to metasfresh community and i’m happy i joined it. I started to follow this setup and i’m blocked at step 5. I installed i think all the modules from metasfresh and also metasfresh-webui-api but InteliJ doesn’t detect Spring Boot run configurations. Can someone please help me with this setup?

Some specs about my PC:

  • Windows 10 Pro
  • InteliJ IDEA Community
  • CPU i5
  • RAM 8GB

#6

Hello @nelucristian,

Idea Community edition does not support Spring, only Ultimate version does (ref: https://www.jetbrains.com/idea/features/editions_comparison_matrix.html).

What you could do is:

  • try to run the class WebRestApiApplication w/o spring config but with the needed arguments – maybe that works, i’m not sure as i have Idea Ultimate version
  • buy and use Idea Ultimate version
  • use eclipse, for which we have a guide at http://docs.metasfresh.org/pages/developers/index_en

Here’s the relevant config i have in my idea:



#7

Thank you very much. I made changes at the run configuration which you specified by screenshots and now WebRestApiApplication it starting also in InteliJ IDEA Community.

I can not start unfourtunatley ServerBoot because it fails at compilation stage. OutOfMemory error when compile ‘ModelClassGenerator’. I have just 8 GB of RAM in my PC. I will upgrade to 16GB