Creating a .modl file of external Java Drivers code using Gradle in IntelliJ

I want to create a .modl file using gradle intelliJ. But I am not able to create this file. I have 4 classes of Java in my src. I am not able to sync the java project with the Gradle. How should I create this .modl file in the gradle. Please tell me the steps to build module of this third-party Java code in IntelliJ. I want to install this module in the Ignition

I have moved your post to the Module Development forum. You should get better and quicker responses here.

What errors are you getting when trying to sync to gradle or build the module?

2 Likes

By far the easiest way to approach this is going to be to start from an example module, then rip out the code and replace it with your own.

For example:

There's even an IU series that covers the basics of Gradle and Ignition integration:

2 Likes


I am getting this error while loading the gradle file in IntelliJ while trying to run this example. GitHub - inductiveautomation/ignition-sdk-examples: Ignition SDK Example Projects


I am getting this error when I am buiding this repository from Git hub git clone GitHub - inductiveautomation/ignition-module-tools: Tools that help in the creation and development of Modules for Inductive Automation's Ignition.. When I put this command gradlew.bat clean build. Please help!

What version of Java are you using to run Gradle? Don't use anything past 17 at the moment; our module plugin isn't tested with newer versions.

1 Like

Hello!
I am using java jdk 11 version which is compatible with Ignition 8, still I am facing the build error.

My Above error is solved! Thank you very much


Hello! I am facing this error when I am building ignition-module-tools repository on gradle. Please help.

Just delete that line for now. As the documentation above suggests, it's currently only relevant for 8.3 module development and likely not fully ready for public consumption.

1 Like

Care to share what resolved it? I am seeing the same message.

I'm using a later version of Java, so going to change that, but please post a solution when you find it rather than just "It's Fixed!"

2 Likes

The problem is solved as I replaced the 'moduleDependenciesSpecs' with 'moduleDependencies.set(mapOf<String, String>())'

1 Like

I've logged an issue in our ignition-module-tools repo related to the error above.

While removing moduleDependenciesSpec will result in a successful build, the better workaround might be to replace the plugin configuration at the top of your root build.gradle.kts with version 0.3.0 (latest at time of writing).

3 Likes

I am getting this error while building gradle project. Please help


image

Can you post your full build.gradle?

1 Like

This is my build.gradle file

'''plugins {
id("io.ia.sdk.modl") version "0.1.1"
kotlin("jvm") version "1.8.10"
java-library
}

val sdk_version by extra("8.1.20")

allprojects {
version = "0.0.1-SNAPSHOT"

repositories {
    maven {
        url = uri("https://nexus.inductiveautomation.com/repository/public")
    }
    mavenCentral()
}

}

subprojects {
apply(plugin = "java-library")

repositories {
    maven {
        url = uri("https://nexus.inductiveautomation.com/repository/public")
    }
    mavenCentral()
}

dependencies {
    implementation(files("libs/Iddk2000-3.3.3.jar"))
}

tasks.register("printRepositories") {
    doLast {
        println("Repositories for project ${project.name}:")
        repositories.forEach { repo ->
            println(" - ${repo.name}: ${(repo as? MavenArtifactRepository)?.url}")
        }
    }
}

}

// Custom task to adjust the module.xml file after the build
tasks.register("finalAdjustModuleXml") {
doLast {
val moduleXmlFile = file("build/moduleContent/module.xml")
if (moduleXmlFile.exists()) {
val lines = moduleXmlFile.readLines().toMutableList()
val adjustedLines = lines.map { line ->
when {
line.contains("<jar scope="G">rs-jar-0.0.1-SNAPSHOT.jar") -> {
null // Remove this line
}
else -> line
}
}.filterNotNull().toMutableList()

        // Check if the line with Iddk2000-3.3.3.jar is present, if not, add it
        if (!adjustedLines.any { it.contains("Iddk2000-3.3.3.jar") }) {
            val index = adjustedLines.indexOfFirst { it.contains("</module>") }
            if (index != -1) {
                adjustedLines.add(index, "<jar scope=\"GD\">Iddk2000-3.3.3.jar</jar>")
            }
        }

        moduleXmlFile.writeText(adjustedLines.joinToString("\n"))
        println("Adjusted module.xml file.")
    } else {
        println("module.xml file not found!")
    }
}

}

// Ensure the final adjustment task runs after the build is complete
tasks.named("build") {
finalizedBy("finalAdjustModuleXml")
}

ignitionModule {
name.set("RS Jar")
fileName.set("RS-Jar.modl")
id.set("com.iritech.demo.rsjar.RSJar")
moduleVersion.set("${project.version}")
moduleDescription.set("A short sentence describing what it does, but not much longer than this.")
requiredIgnitionVersion.set("8.1.11")
projectScopes.putAll(mapOf(
":client" to "CD",
":common" to "GCD",
":designer" to "D",
":gateway" to "G"
))
moduleDependencies.set(mapOf<String, String>())
hooks.putAll(mapOf(
"com.iritech.demo.rsjar.gateway.RSJarGatewayHook" to "G",
"com.iritech.demo.rsjar.client.RSJarClientHook" to "C",
"com.iritech.demo.rsjar.designer.RSJarDesignerHook" to "D"
))
skipModlSigning.set(true)
}'''

Can you put this into a code block so that it's legible? First impression though, you should not be modifying the module.xml file yourself.

You should list your dependency as a modlApi dependency, and let the plugin package it up for you and generate the correct module.xml on its own.

dependencies {
    modlApi(files("libs/Iddk2000-3.3.3.jar"))
}
Gradle Plugin Dependency Configuration
Configuration Usage Suggestion Included in Module? Includes Transitive Dependencies In Module? Exposes Transitive Dependencies to Artifact ConsumersËź?
compileOnly Use for 'compile time only' dependencies, including ignition sdk dependencies. Similar to maven 'provided'. No No No
compileOnlyApi Use for 'compile time only' dependencies, including ignition sdk dependencies. Similar to maven 'provided'. No No No
api Project dependencies that do not explicitly get registered in the module DSL project scopesâśť No No Yes
implementation Project dependencies that do not explicitly get registered in the module DSL project scopesâśť No No No
modlImplementation Dependencies that are used in a module project's implementation, but are not part of a public API Yes Yes No
modlApi Dependencies that are used in a module project and are exposed to dependents​:latin_cross::latin_cross: Yes Yes Yes
1 Like

I am Trying to add a .jar file to ignition. The .jar file contains java classes to access device driver of a device. I want to access that device through ignition platform. I am trying to add it by creating a .modl file through Gradle. I want to call the device drivers on ignition designer script console. Plese help me with elaborative steps to do so. Thank you in advance.

If you want a full example, my Orekit module exposes a full set of Java classes through scripting. It’s an 8.0 module, but most everything should still apply.

The external decencies are listed in the common module’s build.gradle, and are loaded into Ignition’s script manager through a custom ExtendedScriptManager.

1 Like

Okay I'll see this... initially I'm just trying to implement my jar file in the ignition framework ignition -module- tools