I am using the jaxb2-annotate-plugin to add project lombok annotations to my generated java code. In some cases, the plugin is adding optional (in this case experimental) extra information to the annotation.
The annotation class is lombok.NoArgsConstructor, which has optional experimental parameter onConstructor
Typical and expected output should simply be:
@NoArgsConstructor
public class Foo ...
But what I am getting is
@NoArgsConstructor(onConstructor = {
})
public class Foo ...
I do not want the added parameter (not sure what the proper term for that is), and in addition, it is incorrect, as it requires additional information, in this case, annotations to add to the generated constructor.
So 2 questions:
How can I suppress this added information?
If I did want this added parameter, how would I add the necessary additional information?
thanks, Linus
ps. As an aside not directly related to the question: This plugin is new to me. I have modified the build.xml file from one of the provided samples to run xjc with the plugin via ant. While the code is being properly generated, the output appears to say otherwise. The verbose ant output follows. The build.xml file is from jaxb2-annotate-plugin-master/samples/annotate/target/test-ant-assembly/jaxb2-annotate-plugin-sample-annotate-1.1.1-SNAPSHOT/
ant -verbose generate-sources JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
Apache Ant(TM) version 1.10.1 compiled on February 2 2017 Trying the default build file: build.xml Buildfile: /Users/kamb/workspace/oads_xml/versions/a0.2/build.xml Detected Java version: 1.8 in: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
Detected OS: Mac OS X parsing buildfile /Users/kamb/workspace/oads_xml/versions/a0.2/build.xml with URI = file:/Users/kamb/workspace/oads_xml/versions/a0.2/build.xml Project base dir set to: /Users/kamb/workspace/oads_xml/versions/a0.2
parsing buildfile jar:file:/opt/local/apache-ant-1.10.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/opt/local/apache-ant-1.10.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file [property] Loading Environment env. Override ignored for property "java.home" Build sequence for target(s) `generate-sources' is [generate-sources] Complete build sequence is [generate-sources, check, compile, package, install, test-compile, test, clean, ]
generate-sources:
[xjc] build id of XJC is 2.3.0
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/bindings.xjb
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/commonTypes.xjb
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/person.xjb
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/variables.xjb
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/commonTypes.xsd
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/oads_metadata_a0.2.xsd
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/person.xsd
[xjc] Checking timestamp of /Users/kamb/workspace/oads_xml/versions/a0.2/variables.xsd
[xjc] the last modified time of the inputs is 1553044581000
[xjc] the last modified time of the outputs is -9223372036854775808
[xjc] Consider using / so that XJC won't do unnecessary compilation
[xjc] Compiling file:/Users/kamb/workspace/oads_xml/versions/a0.2/commonTypes.xsd and others
[xjc] Writing output to /Users/kamb/workspace/oads_xml/versions/a0.2/gen_src
[xjc] Command invoked: xjc/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/bin/java
[xjc] failure in the XJC task. Use the Ant -verbose switch for more details
/Users/kamb/workspace/oads_xml/versions/a0.2/build.xml:106: xjc failed
at com.sun.tools.xjc.XJCBase.execute(XJCBase.java:731) at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:55) at org.jvnet.jaxb2_commons.xjc.XJC2Task.execute(XJC2Task.java:35) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405) at org.apache.tools.ant.Project.executeTarget(Project.java:1376) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1260) at org.apache.tools.ant.Main.runBuild(Main.java:857) at org.apache.tools.ant.Main.startAnt(Main.java:236) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Ok, on further experimentation, I figured it out.
I needed to use the the Java style annotations, not what I guess is the Old Style which I picked up from looking at older SE questions. So, instead of:
I needed to use:
So simple.