Trouble with extensions

I am trying to create an extension that uses a custom java class. The class will add
four new dice buttons to the chat window. See image below. I created the class in my module (VASL) and it was working from within VASL.

Using other VASL extensions as a model, I created an extension that appears, to my eye at least, to be structured exactly the same as they are. However it is not working. I have the created a link to the extension, SASLDice.vmdx, as I cannot attach it to this message.

It is pretty straightforward, a buildFile and then the compiled classes.

Is there an obvious reason why this isn’t working? When I run VASL, I get a chat message that the SASLDice extension is loaded but it shows version 0.0 rather than version 1.0 which suggests to me that it isn’t working properly. And, of course, the buttons aren’t showing up.

Thanks for any help you might be able to give. I have gone through the Forum looking for extensions issues and have not found any that provide help.

Where’s the source code for the classes in that extension?

In the VASL repo on github, branch feature/dev665:

ASLChattter.java
SASLDice.java (new)

Issue #1114

I built the VASL module with the code changes locally, then added the compiled classes from \target\classes to the extension.

It looks like you’ve included the ASLChatter class in the extension—but that’s already in VASL, right?

The extension looks messed up—it has a buildFile instead of a buildFile.xml and there’s no metadata file. You might want to try recreating it.

Agreed, but create it new using Vassal, not by copying an old extension and cut & paste as you did for the existing version.

Hi

Thanks for this.

Every extension that I opened contained a buildFile not a buildFile.xml. I thought that was how it was supposed to be. I will use buildFile.xml from now on.

Hi and Thanks.

Happy to create it using VASSAL but how do I add the compiled code classes from within VASSAL?

When I tried to use Import A Custom Class all that did was create a buildFile reference to the SASLDice.java file in VASL. The extension “worked” but only because the source code was in VASL, which sort of defeats the purpose.

You need top open the extension vmdx with a Zip utility and manually copy the compiled SASLDice classes in, as you would do for a module. The ‘Import custom class’ just gives you access to custom code that is already in the extension.

Modules and extensions saved with 3.5.0 onward use buildFile.xml instead of buildFile. The latter will still work, but seeing that is what tipped me off that this new extension hadn’t been created by saving it in Vassal.

OK, great.

I seem to be making some progress. I have rebuilt the extension by saving it as an empty extension in vassal then copy-pasting the code file as per Brent and finally editing the buildFile.xml created by VASSAL.

As a result the extension now loads. Unfortunately, it is loading an earlier version of the code file. I cannot imagine where it is getting this from.

I wrote the code file as a class in my local vasl dev version. I then built it with Maven. That gives me two sources for the compiled code file: (1) in the target folder the build process creates a classes folder which has the necessary sub-folders and compiled class file; (2) I can extract the compiled class from the .jar file. Either way, I can then use 7-zip to get the files into the extension.

And I end up with an extension running week old code that I have long since deleted. Where it is finding it, I don’t know.

Next step is to repeat the entire process using different names for everything to see I can rid myself of this troublesome code.

The above process worked. I used different VASL/VASSAL versions and it seemed to break the spell.

Thanks for your help. I took this on because I had never made an extension before (kind of obvious!) and wanted to learn how.

This can be a good way to add optional code features (as well as using preferences).

1 Like