Cannot Import Custom Addon Jar Properly to Application

Hi,

I am essaying the modularity possibilities of JMIX and am trying to import a custom addon I have programmed in a test project (through the single addon wizard in JMIX Studio). I am following as explained in :

https://docs.jmix.io/jmix/modularity/creating-add-ons.html

but I am not getting through.

The custom addon builds fine. I need to produce the jars by executing the “build” gradle tasks in both the functional and the starter modules.

Then I locate the jars in the correspondent project subfolder and via a MVN command I install both jars in my local repository via the instruction:

mvn install:install-file -Dfile=centraladdon-0.0.1-SNAPSHOT.jar -DgroupId=com.sofia.addons.central -DartifactId=centraladdon -Dversion=0.0.1 -Dpackaging=jar

Everything works fine, and both jars get in the repository at the expected maven path.

Then I create a new project as JMIX application and int the build.gradle file I include “mavenLocal()” inside repositories for it to search in my local mvn repository and in dependencies add the line:

implementation “com.sofia.addons.central:centraladdon-starter:0.0.1”

which is the full path to my local mvn jar file

It builds fine.

However the classes defined in the functional model are not importable in any java file inside the target project.

Don’t know why. I have checked other projects where I imported custom libraries and the procedure was, if not identical, very similar.

In the guideline, it is stated that the functional jar should be transitively included via the starter jar.

Any help is greatly appreciated.

Regards,
Carlos.

Ok I think I made some progress. Found the publishToMavenLocal and some things got fixed. So now I am able to successfully build the jars in my mvn local repo properly.

Now when I try to use this addon in another addon, I insert the dependency in build.gradle such as:

dependencies {
classpath “io.jmix.gradle:jmix-gradle-plugin:1.0.3”
classpath ‘com.sofia.addons:centraladdon-starter:0.0.1-SNAPSHOT’
}

I came across another error, somekind of jmix dependency was not being found and got it solved by adding the repo “Repository - Nexus Repository Manager”.

That fixed it.

So now everything builds fine, but still I am not being able to import my imported “central” addon entities in my project/addon (additional addon named “projects”).

Thanks and regards,
Carlos.

Hi Carlos,

When using an add-on (A) in another add-on (B), add implementation 'com.company:A-starter:0.0.1-SNAPSHOT' not to the root build.gradle of B but to B/B.gradle file.

You can also use the Composite Projects feature in Studio. See more details in the article: Add-ons and Composite Projects.

Many thanks Konstantin for your answer.

Haven’t tried yet with another addon but have succeeded at least with an application.

Dummiest thing ever. My problem was not refreshing libraries in IntelliJ. All the rest was correct. Sorry for that.

Will take into account both of your suggestions.

Many thanks again and regards.

Carlos.