Programmatically Update Third-Party Modules

I think I figured everything out. Here is the full solution to run the designer from IntelliJ with my module code:

  1. Create a new run configuration in IntelliJ called DesignerStartupHook
  2. Click 'Modify Options' in the top right and enable the following:
  3. Set your classpath variable in the 'Build and Run' section of the run configuration to '-cp designer-launcher' (package that contains the pom.xml file previously discussed in this thread)
  4. Set the SDK to match that of your designer-launcher package and set the 'Main class' variable to com.inductiveautomation.ignition.designer.DesignerStartupHook
  5. Put the following VM flags in the 'VM options' section. Note: your paths to various folders might be different:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/java.awt.event=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.tree=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.plaf=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.plaf.synth=ALL-UNNAMED
--add-exports=java.base/sun.security.action=ALL-UNNAMED
--add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED
--add-exports=java.desktop/com.sun.awt=ALL-UNNAMED
--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED
--add-exports=java.desktop/sun.awt=ALL-UNNAMED
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED
--add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED
--add-exports=java.desktop/sun.awt.windows=ALL-UNNAMED
--add-exports=java.desktop/sun.swing=ALL-UNNAMED
--add-exports=java.desktop/sun.swing.plaf.synth=ALL-UNNAMED
--add-exports=java.desktop/sun.swing.table=ALL-UNNAMED
--add-exports=java.desktop/sun.print=ALL-UNNAMED
-Dsr.gateway=localhost:8017
-Dautologin.username={your username}
-Dautologin.password={your password}
-Dignition.version=dev
-DlibPath="C:\Program Files\Inductive Automation\Ignition8.0.17\user-lib\pylib"
-Dpython.home="C:\\Program Files\\Inductive Automation\\Ignition8.0.17\\lib\\core\\common\\jython-2.7.1-ia5.jar"
  1. Go to File->Project Structure->Libraries. In the box on the right, click the '+' icon and navigate to the Ignition directory that contains all the jar files for the native Ignition modules. My jar directory path looks like this:
    "C:\Program Files\Inductive Automation\Ignition8.0.17\data\jar-cache"
    Inside of this directory are subdirectories of each module. Simply select all of these directories and add them to your project library.
  2. IMPORTANT In order to use the module code you currently have typed out in IntelliJ, you need also need to add your path to your fully built .modl file into the project library. You also need to install your .modl file on the gateway at least once so the Designer can see and update your module from the GatewayInterface side.
  3. Upon adding your .modl file to the project library, IntelliJ will ask you what to do with it, because it doesn't recognize the file structure. Select "Classes" and "Jar Directory" from the available options.

After doing all this, run your new configuration. Your Designer session should open with no errors if you added all jars to the project library correctly.

If you are reading this somewhere down the line and have questions or issues, feel free to DM me.

1 Like

Update:

When using "-Dautologin.username" and "-Dautologin.password" on a remote gateway (I am attached to the network via VPN) the username and password aren't actually passed to the login. Is this simply because I am connecting to a remote gateway?

The autologin parameters only do anything if -Djavaws.ignition.debug=true is also set.

1 Like

Is there an argument that I can use that allows me to launch a client from the programmatically-launched Designer? When I got to Tools>Launch Windowed I get the following error:

16:02:07.194 [DesignerExecEngine-1] ERROR Vision.DesignerModule -- Java process launch failed with error code 1:no other information is available

Probably not, but you can launch a Vision client using a very similar procedure as launching the designer.

Start from this set of runtime args (n.b. these will all be different in 8.3)

-Djavaws.sr.gateway.addr.0=localhost:8088
-Djavaws.sr.scope=C
-Djavaws.sr.main=com.inductiveautomation.factorypmi.application.runtime.ClientLaunchHook
-Djavaws.sr.runtimeOverride=true
-Djavaws.sr.project=test

And a main class name of com.inductiveautomation.ignition.client.launch.BootstrapSwing.

What should I put for the -cp argument? I tried using my module's client submodule. This allows the main class to resolve, but then throws this error on launch:
Error: Could not find or load main class com.inductiveautomation.ignition.client.launch.BootstrapSwing Caused by: java.lang.ClassNotFoundException: com.inductiveautomation.ignition.client.launch.BootstrapSwing

Update: In IntelliJ I allowed "Adding dependencies with 'provided' scope to classpath". This resulted in the following:

Initialization performed successfully JVM-wide ObjectInputFilter set up successfully Platform serialFilter has 88 pattern(s) Launch parameter "javaws.sr.main" missing.

Much like you had to create a custom pom for the designer launcher, you'll need one for the client "launcher". See the client-launcher pom example in the vision component SDK example:

That means you're not supplying the arguments I called out above as VM options - check you're in the right section of IntelliJ's run/debug configuration dialog, which is an utter disaster.

1 Like

This opens the launcher, but it fails with the following message:

Error launching application: Validation Exception: JPMS Module opens/export check failed! check your --add-opens and --add-exports clauses

Yeah, you're going to need (probably) all the same add-opens and add-exports args as are required for designer launching.

I added basically all the args from my designer session and it worked like a dream. Thanks for your help!