Custom module class imported package class not found

Dear all,

I have create a custom control in an existing module. In this I would like to use an CSV import method by using the openCSV package. All is well and build correctly, but when trying to run it in VASSAL by importing the class I get an exception the class could not be found (an class inside the imported package .jar file).
The package is automatically added to M2\repository folder, as all the other packages.
Is there an additional step to do before being known inside VASSAL? Or is the only way to import the classes of the inside the .jar file?

With kind regards,

Arjen van Hoeve

Any custom classes you want your module to load must be inside the module file.

See the module template for an example.

that I understand, but when a the custom module class uses a package like openCSV, how can VASSAL know this package?

The same way. You package all dependencies inside the module.

To do that automatically, you can use the maven-shade-plugin, as VASL does:

I have had this problem longer, when I try to use the mvn command I get the following exception:
DownloadFile with 2 arguments: An exception occured during a WebClient request.
Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain.
Any solutions for this?

What’s the exact command you’re running? What’s the complete output? (Use triple backticks to fence code and ouptut to make it readable in forum posts: ``` CODE HERE ```.)

MVN build worked.
I think I now have the same classes as I already had with a build inside my editor.
But I am still having problems with the linked library, since that is not anywhere linked to the codes. Any suggestions?

What linked library? I need more details to know what you’re referring to.

I am using the library/package called openCsv for loading in a csv file. This package is also saved by maven in my C:\Users\username.m2\repository\com folder. How do you make sure this is usable by VASSAL?

The maven-shade-plugin I mentioned above should unpack any dependent JARs you have and include them in the resulting module when you run mvnw package. (See lines 109-130.)

That finally did it. Still quite a workaround for this to work.
Is there any way to make the generated jar file being used in VASSAL directly?

I don’t understand yet what you’re working around. The generated JAR file—the one built by mvnw packageis the module, and that’s used by Vassal directly.

Would you restate what it is you’re aiming to do? How is using the maven-shade-plugin not achieving that?

I don’t know how to use the created jar file in VASSAL. When I rename it to vmod, it says there are files missing. That is the final step for me.

Would you post the error message? What files does it say are missing?

The file ‘C:\Users{user}\Downloads\OA_VASSAL\OA Demo Game\NameOfModule-0.0.1-SNAPSHOT.vmod’ is not a valid VASSAL module.
But I do see that the .jar file does not contain a buidlfile.xml and moduledata, could that be the reason?

Yes, that would cause you not to have a valid module.

Are those two files not in dist/? You have to put all of the non-class files you want to be in the module in dist/, as per the instructions for the module template.

And that is it…maybe these things can be made slightly more clear in the github page, along with:

  • name the location where the errorlog/log file is: C:\Users{user}\AppData\Roaming\VASSAL.
    Thank you so much for the help.
    I wish you a great day!

What would the instructions need to say to be clearer?

I think you can see in this ticket what my problems have been and not was put on that page.

  • What files specifically(or minium to make it work) need to be in dist.
  • a link to the shadow part would be really useful, because many people are using external packages in their module.
  • the location to where a logger location file, as I mentioned in previous message

I’ve added the maven-shade-plugin to the pom.xml disabled and with some comments, added a minimal buildFile.xml and moduledata to dist/ so that a module can be built without adding anything to the module template after checking it out, and updated the README:

1 Like