How do I exclude a protected method from javadoc?
I need to document some but not all protected methods.
Thanks
You can exclude all protected methods with the command line option "-protected", but I just re-read your question more closely and realize this is probably not what you are looking for.
You can't do this with straight Javadoc but, depending on what other javadoc facilities you need, and how it is you are generating your javadoc, you could consider switching to Doclava. Doclava is a doclet (think: plug-in) for javadoc and it does recognise the #hide tag.
The HTML output is much prettier too.
Unfortunately it doesn't recognise large swathes of javadoc command line options, so it may not be suitable.
https://code.google.com/p/doclava/
If you are using the maven plugin, you can use the show tag into the configuration tag with value public as shown below. In that case, only public members of classes will be displayed into javadoc.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<show>public</show>
<doctitle>My company API</doctitle>
<subpackages>my.company.package.api</subpackages>
</configuration>
</plugin>
Related
There is an option in GWT to obfuscate enum names:
<set-configuration-property name="compiler.enum.obfuscate.names" value="true" />
When I use this option, my compiles produce a warning:
[WARN] Call to Enum method name when enum obfuscation is enabled:
com/google/gwt/dom/client/DataTransfer.java:127
Looking at the DataTransfer source code, I can see that it has an enum DropEffect and the enum names are used in one of the methods (setDropEffect).
I'm using modern JsInterop-oriented GWT, so I'm not using this DataTransfer class (or anything in gwt-user.jar). It's annoying to have a useless warning. Is there an easy way to get rid of it?
I know how to exclude files in my own source folders.
Is it possible to exclude source folders from gwt-user? (Other than by physically deleting files from the jar!)
That looks like a bug - unfortunate too that the compiler doesn't remove this class. This should be easy to fix with a patch to GWT, adding a field to DropEffect for the name, since it must never be removed even when that compiler flag is enabled.
Is it possible to exclude source folders from gwt-user? (Other than by physically deleting files from the jar!)
What you must do is exclude the .gwt.xml file itself, by not inheriting it at all, even transitively. So, for example, if you do avoid all JSNI including Widget types in the User module, your .gwt.xml shouldn't reference the Dom module, or User, or anything else which references Dom. But once a module has been inherited, there is no way to "uninherit" it. And once a module is inherited, its sources are added, and cannot be un-added.
I tried to use Saxon in place of JDK's default implementation (Xalan I guess) for XML transformation and Xpath. In my code I am creating a CDATA node using document.createCDATASection(data) method. Code looks as given below:
CDATASection cdata = doc.createCDATASection("data");
Node valueNode = node.appendChild(doc.createElement("value"));
valueNode.appendChild(cdata);
Where node is some random node in my XML.
It works fine with JDK's default implementation and resulting XML looks like:
<node>
<value><![CDATA[data]]></value>
</node>
The same code starts behaving strange if I include Saxon maven artifact (Please note it is just inclusion and factory selection/instantiation is default, as it was earlier) and all the cdata nodes are treated as simple text nodes i.e. XML becomes:
<node>
<value>data</value>
</node>
which on retrieval is causing issues as that code specifically checks for cdata elements which in later case has been removed. I am not sure why this is happening (looks like I have not used it correctly). I also tried excluding Xerces artifacts from my POM (transitive dependency for Saxon) but no luck. Also, verified that implementation classes for DocumentBuilderFactory etc are being used from JDK itself. Experts please help me if I am doing something wrong.
Thanks in advance.
I guess your application is probably doing a JAXP identity transformation from a DOMSource to a StreamResult in order to serialize the DOM. The Saxon implementation of the JAXP identity transformation uses the serialization rules of XSLT, which have the effect of dropping CDATA sections. This is perfectly conformant with JAXP, even if it isn't what the default JDK implementation does.
If you are dependent on the behaviour of a particular implementation of the JAXP identity transformer, then you shouldn't be writing your application to pick up whatever implementation happens to be lying around on the classpath; you should instantiate the implementation you want explicitly.
This can be difficult of course if the code that invokes the identity transform is something you didn't write yourself and can't easily change. In that case the best approach is to set the system property javax.xml.transform.TransformerFactory to select Xalan, and where you want to invoke Saxon, do it explicitly rather than relying on the JAXP factory search.
In my eclipse, when i check for method help with ctrl+space i see the method parameters are showing like strings, int as arguments. Not showing like, string name/int id .
getAttribute(String arg0)
How can i make the eclipse to show the method as getAttribute(String name)
This is really difficult to me identify which param i should pass fro a method.
Any idea, where should i set the settings?
This problem happens when eclipse can't find the source or attached Javadoc, since java argument names are usually not present in the .class files (it would only be present in debug, and not for the interfaces).
You can check if a source or a documentation is attached using the helper F3.
You can increase the timeout eclipse uses for fetching a parameter name from attached Javadoc in the settings.
You can also attach the corresponding documentation jar or source jar as a dependency in order to allow eclipse to look-up the corresponding source.
I have an application which has legacy Struts actions extending org.apache.struts.StrutsActions. I would like to be sure that all my classes which are extending StrutsActions have a custom annotation.
In order to provide this I have written a small maven enforcer rule to validate my requirement. However I dont know how to load my classes at my mojo to validate them.
Actually I have done something not fancy which is injection outputDirectory and with a custom class loader I have recursively loaded all classes at my build folder.
Thanks
All classes ? What do you mean by that ? Maybe you mean target/classes/** (which is the default output place for classes) or maybe you mean a list of multiple directory tree locations ?
Can you better explain what your Mojo does and which phase and goals you want it to bind with.
I think maybe you are thinking about how to apply Maven's build cycle to your project incorrectly. Could you explain better what your plugin does, maybe it is does "packaging" work ?
But if I understand you correctly you want the plugin's execution to pickup the additional classpath entry for target/classes/** ? So it can load code and resources from the project itself to change some dynamic behaviour inside the maven-plugin ?
The default way to do this is <dependency> however of course this requires a fixed unit.
Other plugins that allow for this behavior (like maven-antrun-plugin) provide a mechansism to change classpath inside the Mojo and use something from <configuration> section of their pom.xml to do it. It is not clear if the plugin you are using is a Maven one or one you have written ?
.
Validation and packaging that is a valid use case. But I question why on the "classpath" ? I would guess you are binding on process-classes phase.
i.e. the classpath is for the purpose of providing code/resources to the runtime to execute. But in your case you have an input directory rather than a class path requirement.
It is possible in a Mojo to setup a directory scanner on an input directory */.class and then it is possible to (using some library) open each file and inspect the annotation without loading it.
This is also a good kind of separation between unreliable input data and the consistent behaviour of the plugin code itself. What happens if a project decides it wants to implement the same package and/or class as used in the implementation of the plugin itself.
UPDATE: If you really are loading the classes you are checkig into the JVM from your Mojo, then at least implement your own ClassLoader to do it. This is not necessarily a simple problem to solve. You make this ClassLoader find things specified from configuration in the input directory.
I have done it with the help of reflections
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.5</version>
</dependency>
my implementation is like this:
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
URL url = getURL(helper.evaluate("${project.build.outputDirectory}"));
Predicate<String> filter = new FilterBuilder().include(getTargetSuperTypeForSubtypes());
Predicate<String> filter2 = new FilterBuilder().include(getMustHaveAnnotation());
Reflections reflections = new Reflections(new ConfigurationBuilder()
.setScanners(
new TypeAnnotationsScanner().filterResultsBy(filter2),
new SubTypesScanner().filterResultsBy(filter))
.setUrls(url));
validate(reflections);
}
I use CssResource extensively, and now my generated html is full of GWXSHFKADAish class names. I get all of the advantages of that, but for debugging it'd be helpful to add a flag that would turn .selected into GWXSTY_selected. Is there any way to do this?
When you set
<set-configuration-property name="CssResource.style" value="pretty"/>
in your .gwt.xml file, then the resulting class names will contain the original class name.