Archived
Slice2java - How to add command option (i.e. --underscore) to Ant Task Def
Hi All:
Please see the below maven ant plugin pom.xml. I am trying to add the "--underscore option" to the task definition. I read your wiki (https://doc.zeroc.com/display/Ice35/Slice2Java+Ant+Task). I tried to add , but the slice2jva is still complaining that my ice file has underscores. Thanks much for any help
maven-antrun-plugin
${maven-antrun-plugin.version}
generate-sources
run
com.zeroc
ant-ice
${ant-ice.version}
Comments
-
it looks my pom.xml snipped was to rendered as I expected
<build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>${maven-antrun-plugin.version}</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <target name="slice2java"> <taskdef name="slice2java" classname="Slice2JavaTask" classpathref="maven.plugin.classpath" /> <slice2java outputdir="src/generated/java" > <define name="--underscore"/> <fileset dir="src/main/resources" includes="neti.ice" /> <includepath> <pathelement path="${ice.include.path}" /> </includepath> </slice2java> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>com.zeroc</groupId> <artifactId>ant-ice</artifactId> <version>${ant-ice.version}</version> </dependency> </dependencies> </plugins> </build>
0 -
Hi,
What version of slice2java are you using? this option was removed in 3.7 it was replaced by underscore file metadata for example with 3.7 you can use
[["underscore"]]
in your Slice files that needs to use underscores.
0 -
Hi xdm:
Thanks for your prompt reply. I am using 3.7.5. I basically have two issues:
1. want to still use underscore as per below ice file:module NetiClient { enum NetiDescriptorType { DATA, SQL, SOLR }; enum ResourceMatchingScope {SELF, **SELF_OR_DESCENDANTS**}; class NetiRequestDescriptor { NetiDescriptorType type; Value data; Value dataAfterEntitlement; string command; string commandAfterEntitlement; }; }
- Based on your response I need to update my ice file to something lik
enum ResourceMatchingScope {SELF, SELF[["underscore"]]OR[["underscore"]]DESCENDANTS};
I tried this and the slice2java complained.
- I want to use maven-antrun-plugin to generate the java source code, compile them and build a jar
0 - Based on your response I need to update my ice file to something lik
-
BTW the command line below will not complain and generate the source code. Because of that I thought to somehow add the "--underscode" to the ant task def for slice2java but got stuck how to add this option
slice2java --underscore /Users/*****/workspace/neti/neti-slice/src/main/resources/neti2.ice
0 -
I was wrong before the option was deprecated but still works, it will be better to upgrade your slice definitions to use file-metadata as in
[["underscore"]] module NetiClient { ... }
The ant task doesn't support
--underscore
optiondefine
is for preprocessor definitions, we mostly use Gradle these days, and the ant task was not updated to support this option.0 -
you can try
<slice2java underscore="on"
I think it was not supported because it is not mentioned in the docs but looking at the code there is support for it.
Anyway switching to file metadata seems better given that
--underscore
is now deprecated0 -
Thanks much xdm!!! In fact I was looking at the ant-ice code too, but could not figure it out. Your first option works (adding to the ice file). I will also try your second option for completeness. Again Thanks much!!!
1 -
Hi xdm:
I am still trying to get the maven-ant plugin work. Below is the "issue" got it from running "mvn clean install" and the corresponding maven pom.xml config snipet:- Issue:
slice2java: Class Slice2JavaTask loaded from parent loader (parentFirst) +Datatype slice2java Slice2JavaTask fileset: Setup scanner in dir /Users/achouic/workspace/neti/neti-slice/src/main/resources with patternSet{ includes: [neti.ice] excludes: [] } [slice2java] skipping neti.ice [INFO] Executed tasks
- mvn config
<plugin> <!-- <groupId>com.morningstar.neti</groupId> --> <artifactId>maven-antrun-plugin</artifactId> <version>${maven-antrun-plugin.version}</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <target name="slice2java"> <taskdef name="slice2java" classname="Slice2JavaTask" classpathref="maven.plugin.classpath" /> <slice2java outputdir="src/generated"> <fileset dir="src/main/resources" includes="neti.ice" /> <includepath> <pathelement path="${ice.include.path}" /> </includepath> </slice2java> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>com.zeroc</groupId> <artifactId>ant-ice</artifactId> <version>${ant-ice.version}</version> </dependency> </dependencies> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>${build-helper-maven-plugin.version}</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <!-- <source>${project.build.directory}/generated-sources/slice/</source> --> <source>src/generated</source> </sources> </configuration> </execution> </executions> </plugin>
0 -
[slice2java] skipping neti.ice
just means that the generated code is up to date, and the Slice file doesn't need to be recompile.0 -
Thx much. Really appreciate it!
0