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

**URL:** <https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210>\
**Category:** Module Development\
**Created:** [July 15, 2024, 6:44am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210 "2024-07-15T06:44:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 15, 2024, 6:44am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/1 "2024-07-15T06:44:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 15, 2024, 12:05pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/2 "2024-07-15T12:05:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 15, 2024, 1:58pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/3 "2024-07-15T13:58:25Z")

</div>

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:

> **[GitHub - inductiveautomation/ignition-sdk-examples: Ignition SDK Example...](https://github.com/inductiveautomation/ignition-sdk-examples)**
>
> Ignition SDK Example Projects. Contribute to inductiveautomation/ignition-sdk-examples development by creating an account on GitHub.

> **[GitHub - IgnitionModuleDevelopmentCommunity/ignition-extensions](https://github.com/IgnitionModuleDevelopmentCommunity/ignition-extensions)**
>
> Contribute to IgnitionModuleDevelopmentCommunity/ignition-extensions development by creating an account on GitHub.

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

> **[Module Development with the Ignition SDK Course at Inductive University](https://www.inductiveuniversity.com/courses/elective-studies/module-development-with-the-ignition-sdk)**
>
> The Ignition SDK opens up Ignition to all kinds of user/organization extensions and customizations. This course will introduce you to the basic foundations of Ignition SDK module development, from ground zero upward.

> **[GitHub - inductiveautomation/ignition-sdk-training: Examples and materials...](https://github.com/inductiveautomation/ignition-sdk-training)**
>
> Examples and materials for SDK educational content provided by the Inductive Automation Training team. - inductiveautomation/ignition-sdk-training

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 18, 2024, 11:30am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/5 "2024-07-18T11:30:52Z")

</div>

![Screenshot 2024-07-18 165659](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/870a2f0512e2679d300f2fa05ba78ef312199b6b.png)  
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](https://github.com/inductiveautomation/ignition-sdk-examples)

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 19, 2024, 12:27pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/6 "2024-07-19T12:27:08Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/5/a5b16c6efbcc5c101ca5e330b98c0189f2b86249.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/0/30ae1189b34e84cb5423479c5e38209fe3db1cb7.png)

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.](https://github.com/inductiveautomation/ignition-module-tools). When I put this command gradlew.bat clean build. Please help!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 19, 2024, 3:19pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/7 "2024-07-19T15:19:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 22, 2024, 7:17am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/8 "2024-07-22T07:17:49Z")

</div>

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

 ![Screenshot 2024-07-22 124601](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/a/7ac71bad37060a1d5435b696cdd0fd6b92183990.png)

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 22, 2024, 12:51pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/9 "2024-07-22T12:51:46Z")

</div>

My Above error is solved! Thank you very much

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 23, 2024, 7:21am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/10 "2024-07-23T07:21:00Z")

</div>

![Screenshot 2024-07-23 124833](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0eaa169ef160f550b623536336b82206c9f028ba.png)  
Hello! I am facing this error when I am building ignition-module-tools repository on gradle. Please help.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 23, 2024, 2:54pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/11 "2024-07-23T14:54:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JoeJansen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joejansen/32/5277_2.png) [@JoeJansen](https://forum.inductiveautomation.com/u/JoeJansen)\
**Post date:** [July 23, 2024, 8:48pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/12 "2024-07-23T20:48:13Z")

</div>

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!"

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 24, 2024, 9:07am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/13 "2024-07-24T09:07:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [July 24, 2024, 7:20pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/14 "2024-07-24T19:20:41Z")

</div>

I've logged [an issue](https://github.com/inductiveautomation/ignition-module-tools/issues/49) 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`](https://github.com/inductiveautomation/ignition-module-tools/releases) (latest at time of writing).

 ![SCR-20240724-mtjp](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8e51c275c2877e9c8d007f48490826b42f79e8fd.png)

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 26, 2024, 6:03am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/16 "2024-07-26T06:03:40Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8e959a0accb0503968e569bfdfcb3cbebcb2ac96.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/6/267dd502cb75642ad150d9ef8bdcadb08acf2b29.png)

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [July 28, 2024, 4:55pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/17 "2024-07-28T16:55:45Z")

</div>

Can you post your full `build.gradle`?

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 29, 2024, 5:57am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/18 "2024-07-29T05:57:30Z")

</div>

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)  
}'''

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [July 29, 2024, 2:04pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/19 "2024-07-29T14:04:06Z")

</div>

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.

```python
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:✝ | Yes | Yes | Yes |

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 30, 2024, 10:41am UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/20 "2024-07-30T10:41:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [July 30, 2024, 3:08pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/21 "2024-07-30T15:08:04Z")

</div>

> [@Krutika\_Jathe](#):
>
> elaborative

> [@Creating a basic module just to add a java class](https://forum.inductiveautomation.com/t/creating-a-basic-module-just-to-add-a-java-class/51428):
>
> I’m trying to add a jar file to ignition so that i can use it in scripting. I don’t have experience at all in this area, but i was able to download the examples from github and to create a module from that in Eclips IDE. but how can i add the jar file to the example project so that i can be able to call it later in ignition. i have a jposservice.jar and i want to be able to use in scripting import java import jpos What do i need to do to be able to add that to the project and create a modu…

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`.

> **[GitHub - benmusson/ignition-orekit-module: Allows an Ignition gateway to provide OREKIT...](https://github.com/benmusson/ignition-orekit-module)**
>
> Allows an Ignition gateway to provide OREKIT (ORbits Extrapolation KIT) data for connected clients.

---

<div class="post-metadata">

**Author:** ![Krutika\_Jathe](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@Krutika\_Jathe](https://forum.inductiveautomation.com/u/Krutika_Jathe)\
**Post date:** [July 30, 2024, 3:24pm UTC](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210/22 "2024-07-30T15:24:51Z")

</div>

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

[Next page](https://forum.inductiveautomation.com/t/creating-a-modl-file-of-external-java-drivers-code-using-gradle-in-intellij/93210.md?page=2)
