Archived

This forum has been archived. Please start a new discussion on GitHub.

Help with Slice2Java package name

Hi, I have a slice file which is shared by multiple applications. I would like the applications to specify the package name for the generated code, instead of me specifying it in the slice file.

In the forums, there was a reference to something like <slice2java package="MyPackage" ...>, but when I tried it, I am getting the error "slice2java doesn't support the package attribute". Any suggestions, on how I can do this ?

I am using Ice 3.30. Thanks in advance.

Comments

  • mes
    mes California
    Hi,

    You can use the translator option --meta to define the package metadata instead of defining it in the Slice file. For example:

    slice2java --meta java:package:MyPackage Defs.ice

    Here's the equivalent for ant:
    <slice2java ...>
        <meta value="java:package:MyPackage"/>
    </slice2java>
    

    Hope that helps,
    Mark
  • yes, it does. Thank you.

    Just to clarify, I assume the package name specified by the translator option --meta, will override the package name specified using the java::package:: in any slice files that were included in Defs.ice.
  • mes
    mes California
    fd98444 wrote: »
    Just to clarify, I assume the package name specified by the translator option --meta, will override the package name specified using the java::package:: in any slice files that were included in Defs.ice.
    That's correct, which means the --meta option may not be suitable in all situations.

    Regards,
    Mark
  • Got it. Thank you!!