This repo contains a gradle build that helps to easier setup IntelliJ (with regards to vendorlib and userlib dependencies) to develop custom Java code for a Mendix project.
It relies on the gradle build Mendix uses internally (inside the /deployment/ folder) and currently only supports
Mendix Studio Pro and IntelliJ in Windows.
Furthermore the gradle build contains a test dependency on Junit 5 (could easily be changed for your preferred test framework) and could also serve as starting point for Java test automation and other CI Tasks.
ℹ️ This requires Mendix Studio Pro 10.3 or above (first version to support Java managed dependencies a.k.a. vendorlibs)
ℹ️ This only works with IntelliJ / Mendix Studio Pro under Windows
To initialize your existing Mendix project with the gradle setup:
-
copy the following contents of this repo to the root of your project
- the
/gradledirectory - the
/gradlewand/gradlew.batscripts - the
build.gradle.ktsfile - the
gradle.propertiesfile - the
settings.gradle.ktsfile (adjust therootProject.nameproperty to your desired gradle project name)
ℹ️ if you choose to init the gradle project and install the Gradle Wrapper manually, be sure to choose Kotlin DSL and integrate the build script in
build.gradle.ktsfrom this repository to your generatedbuild.gradle.kts - the
-
create the
javatestsourcedirectory in the project root (to contain any java test sources like JUnit tests), -
adjust your
.gitattributesto leave the line endings of the gradlew script LF# Linux start script should use lf /gradlew text eol=lf -
adjust your
.gitignoreto ignore the gradle cache and build directory# Ignore Gradle project-specific cache directory .gradle # Ignore Gradle build output directory build -
hit
App > Deploy for Eclipsefrom the Mendix Studio Pro menu bar, and once that finished -
open the project root directory via IntelliJ
File > Openand chooseGradle Project(instead ofEclipse Project) if asked.
To update dependencies in your IDE:
- add the dependency in Mendix Studio Pro as Java Dependency via the Module Settings,
- run
App > Synchronize Dependenciesfrom the Mendix Studio Pro menu bar, and - run
Reload All Gradle Projectsin IntelliJ from the Gradle Tool Window.
To update the Java Stubs in IntelliJ after changes to Java Actions configuration in Mendix Studio Pro (e.g. adding Parameters or changing the Return type)
- hit
App > Deploy for Eclipsefrom the Mendix Studio Pro menu bar, and after that finishes - in Intellij right click on the Project root in the Project Explorer and select
Reload from Disk.
