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 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
--underscoreoptiondefineis for preprocessor definitions, we mostly use Gradle these days, and the ant task was not updated to support this option.0 -
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
