Skip to content

A sample Mendix project with a custom gradle build to maintain vendorlib/userlib dependencies for better IntelliJ support.

Notifications You must be signed in to change notification settings

hatzlj/mendix-gradle-setup

Repository files navigation

Mendix Gradle Setup

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.

Initialization

ℹ️ 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 /gradle directory
    • the /gradlew and /gradlew.bat scripts
    • the build.gradle.kts file
    • the gradle.properties file
    • the settings.gradle.kts file (adjust the rootProject.name property 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.kts from this repository to your generated build.gradle.kts

  • create the javatestsource directory in the project root (to contain any java test sources like JUnit tests),

  • adjust your .gitattributes to leave the line endings of the gradlew script LF

    # Linux start script should use lf
    /gradlew text eol=lf
    
  • adjust your .gitignore to ignore the gradle cache and build directory

    # Ignore Gradle project-specific cache directory
    .gradle
    # Ignore Gradle build output directory
    build
    
  • hit App > Deploy for Eclipse from the Mendix Studio Pro menu bar, and once that finished

  • open the project root directory via IntelliJ File > Open and choose Gradle Project (instead of Eclipse Project) if asked.

    Open Gradle Project

Updating dependencies

To update dependencies in your IDE:

  • add the dependency in Mendix Studio Pro as Java Dependency via the Module Settings,
  • run App > Synchronize Dependencies from the Mendix Studio Pro menu bar, and
  • run Reload All Gradle Projects in IntelliJ from the Gradle Tool Window.

Updating Java Stubs (Java Microflow Actions)

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 Eclipse from 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.

About

A sample Mendix project with a custom gradle build to maintain vendorlib/userlib dependencies for better IntelliJ support.

Resources

Stars

Watchers

Forks