quickfix-j / quickfixj

QuickFIX/J is a full featured messaging engine for the FIX protocol. - This is the official project repository.
http://www.quickfixj.org
Other
955 stars 611 forks source link

`fieldPackage` parameter not respected in `quickfixj-codegenerator` #670

Closed morvael closed 9 months ago

morvael commented 1 year ago

Maven plugin allows to specify package for generated fields in the fieldPackage parameter (default is "quickfix.field"). When this parameter is specified (because I don't want to use field class overriding that opaque way), field classes are generated in the stated package, but sadly all message classes still use "quickfix.field" in their code, leading to compliation error.

QFJ Version 2.3.1

chrjohn commented 1 year ago

all message classes still use "quickfix.field" in their code,

Where? As their package name or when using import? Could you provide an example? For a project we are generating classes with other package names so it should work, unless I misunderstood something.

morvael commented 1 year ago

Maven plugin configuration:

                        <configuration>
                            <dictFile>${basedir}/src/main/resources/fix/FIX.xml</dictFile>
                            <outputDirectory>${basedir}/src/main/java</outputDirectory>
                            <decimal>true</decimal>
                            <orderedFields>true</orderedFields>
                            <packaging>my.package</packaging>
                            <fieldPackage>my.package.fields</fieldPackage>
                            <utcTimestampPrecision>MICROS</utcTimestampPrecision>
                        </configuration>

What I need to fix afterwards using antrun plugin:

                        <configuration>
                            <target>
                                <replace dir="${project.basedir}/src/main/java/my/package" includes="*.java" token="quickfix.field." value="my.package.fields."/>
                            </target>
                        </configuration>

as the generated code for messages looks like this:

    public quickfix.field.SomeValue get(quickfix.field.SomeValue value) throws FieldNotFound {
        getField(value);
        return value;
    }

    public quickfix.field.SomeValue getSomeValue() throws FieldNotFound {
        return get(new quickfix.field.SomeValue());
    }
chrjohn commented 1 year ago

Could you post the whole plugin config? Or compare it to the one that is used starting from here: https://github.com/quickfix-j/quickfixj/blob/e612ee6858673e6d4e1e21999fbda105e9c283bc/quickfixj-core/pom.xml#L189-L206

Because when I change the fieldPackage in that file and rebuild QFJ, the compiled classes use the custom field package name that I entered in the pom.xml.

morvael commented 1 year ago

Field classes are in the correct place, but have you checked message classes? Maybe you reuse not cleaned old files. I have ommited the rest of config as it contains standard things only (id, goal, phase).

chrjohn commented 1 year ago

Example where I put quickfix.foxi as fieldPackage and then rebuild QFJ.

public Advertisement(quickfix.foxi.AdvId advId, quickfix.foxi.AdvTransType advTransType, quickfix.foxi.AdvSide advSide, quickfix.foxi.Quantity quantity) {
                this();
                setField(advId);
                setField(advTransType);
                setField(advSide);
                setField(quantity);
        }
morvael commented 1 year ago

Yeah, so that's where I had wrong package names...

chrjohn commented 1 year ago

So looks like it works for me but not for you? I assume you are using the plugin in your own project? So maybe there is still something missing from the config?

morvael commented 1 year ago

Can it be something from the FIX.xml file? Other than that I'm not sure, maybe it just needed message files to be deleted (I don't keep them at target dir). I'll experiment with it a bit more.

chrjohn commented 9 months ago

Please reopen when you have new information. Thanks