How to pass command line options to the java compiler through the <javac> Ant task using <compilerarg value="">? - ant

To compile code using preview features, javac requires options --enable-preview and --release.
If I pass these options to the <javac> Ant task (Ant 1.10.5) using the line attribute, as shown below, compilation succeeds.
<compilerarg line="--enable-preview --release 15"/>
But if I pass them as individual arguments using the value attribute, as shown below, Ant throws error: invalid flag: --release 15.
<compilerarg value="--enable-preview"/>
<compilerarg value="--release 15"/>
Since the Ant manual says "It is highly recommended to avoid the line version when possible", I'd like to know how to make the code work with the value attribute as well. What's the trick?

It needs to be three arguments, like:
<compilerarg value="--enable-preview"/>
<compilerarg value="--release"/>
<compilerarg value="15"/>
... otherwise, as you saw, "--release 15" is treated as a single argument with an embedded space.

Related

Ant genkey task doesn't support the "saname" attribute

Any idea how to add the san info in gen key tag in ant 1.9?
I am trying like below, but its not working
<genkey alias="tomcat" validity="3652" keystore="${keystore}"
storepass="security" keypass="security" keyalg="RSA" sigalg="SHA256withRSA" keysize="2048"
dname="CN=XX, OU=XX, O=XX, L=XX, ST=XX, C=X"
*saname="SAN=IP:10.100.0.1,IP:192.168.0.1,DNS:myserver.mydomain.com,DNS:otherserver.otherdomain.com,EMAIL:name#mydomain.com,EMAIL:othename#otherdomain.com"*/>
The error is:
genkey doesn't support the "saname" attribute
I am using jdk-8_261 with Ant 1.9.
This is an issue with Ant versions 1.9.0-1.9.13, fixed in 1.9.14.
Ant downloads are here.

How to solve Checkstyle conflict between #link JavaDoc on one line and line length?

Consider the following JavaDoc:
/**
* Test method for
* {#link MySelectionStyleConfiguration#configureSelectionStyle(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)}.
*
*/
Whenever I save the JUnit5 test class this comment belongs in, the {#link } is re-formatted to be on one line, which is correct, otherwise the Maven Checkstyle plugin will throw an error if I try to introduce a line break in the link: (javadoc) SingleLineJavadoc: Javadoc comment at column 78 has parse error. Details: mismatched input '\n' expecting MEMBER while parsing REFERENCE. (Also I reckon the link wouldn't resolve correctly in the API docs which are rendered from this.)
However, the Maven Checkstyle plugin will also throw an error if I leave the long link line as is: (sizes) LineLength: Line is longer than 100 characters (found 125)..
Is there a way to resolve this?
Requirements:
The 100 char line rule should remain in place, but long {#link } tags in JavaDoc (in test classes most obvisouly, but perhaps also elsewhere) should be excempted.
The link should still resolve in the rendered JavaDoc (i.e., it should remain valid).
Edit
I can leave out the package names from the link, but I'd like to keep them in there so that they resolve to one thing only and not potentially to something that is named equally.
It can be done with "ignorePattern" property of LineLength check https://checkstyle.sourceforge.io/config_sizes.html#LineLength
In your case, something like
<module name="LineLength">
<property name="max" value="100"/>
<property name="ignorePattern" value="^ \* \{#link .*$"/>
</module>
will solve problem.

ANT SCRIPT: http url property value is not loaded and giving error java.net.MalformedURLException: For input string: "${amx.admin.port}"

I am busy with automation of tasks using ant script.
In main properties ( Connection.properties) file I had defined properties values which will be used at runtime in script.
admin.url.protocol=${amx.admin.url.protocol}
amx.admin.hostname=shrijeet
amx.admin.port=8120
amx.admin.url=${amx.admin.url.protocol}://${amx.admin.hostname}:${amx.admin.port}
Later in script another property file (build.properties) is used at runtime where it uses above values as below.
adminURL=http://${amx.admin.hostname}:${amx.admin.port}
Now issue is , whenever script is reading value of "adminURL" property it fails with below error
[AMXAdminTask] 08 Apr 2017 18:15:14 WARN - TIBCO-AMX-CLI-000743: Failed to parse the admin base
url 'http://${amx.admin.hostname}:${amx.admin.port}'. Not a valid url.
[AMXAdminTask] java.net.MalformedURLException: For input string: "${amx.admin.port}".
when I hard code value like adminURL=http://shrijeet:8120 , then script works fine. But I need hostname:port number to be externalised in main connection.properties.
Please suggect is there is any other way to externalize http url type of properties.
I see i have found solution
where i am creating temporary file ,say build-temp.properties and given tokens in property.
Ex
adminURL=adminuRL_temp
And then i am replacing token with values mentioned in Connection.properies file.
In build-temp.properties file:
adminURL=adminurl_temp
username=username_temp
password=password_temp
Target:
<target name="setBuildProperty">
<copy file="${ScriptFilesPath}/StandAloneTibcohost/build-temp.properties" tofile="${ScriptFilesPath}/StandAloneTibcohost/build.properties" overwrite="true"/>
<replace file="${ScriptFilesPath}/StandAloneTibcohost/build.properties" propertyFile="${ScriptFilesPath}/Connection.properties">
<replacefilter token="adminurl_temp" property="adminurl"/>
<replacefilter token="username_temp" property="username"/>
<replacefilter token="password_temp" property="password"/>
</replace>
</target>
This works perfectly and values are now getting updated.

Using ant contrib HttpClientTask with url set to ant's property

I am trying to use ant's property, set based on some condition & passing to http task like:
if test env then
<property name="framed.url" value="http://url.to.check"/>
else if prod env then
<property name="framed.url" value="http://some.other.url.to.check"/>
I am trying to use ant-contrib httpclient task to call URL, like below
<taskdef name="http" classname="org.missinglink.ant.task.http.HttpClientTask">
...
<http url="${framed.url}"
...
but it is giving below error.
org.missinglink.http.exception.InvalidUriException: java.net.URISyntaxException: Illegal character in path at index 1: org.missinglink.http.exception.InvalidUriException: java.net.URISyntaxException: Illegal character in path at index 1: ${framed.url}
How to esacpe / pass ant property to url ?
This worked, after creating a macrodef & making macro-call within if-else evaluation by passing the url.

HDF5 example not working

I tried building the first example here and got errors. Right on the first line there's a missing include statement, but I managed to figure out it should be
#include "hdf5.h"
But even after fixing that I got more errors:
$ h5cc ./example1.c
./example1.c: In function ‘main’:
./example1.c:66:4: error: too few arguments to function ‘H5Dcreate2’
In file included from /usr/include/hdf5.h:27:0,
from ./example1.c:6:
/usr/include/H5Dpublic.h:104:14: note: declared here
Any idea how to solve it?
The example code was written for release 1.6 of hdf5, and as such will simply not compile on a 1.8 release without modification.
If you want to get the code to work on 1.8, you need to enable 1.6 compatibility, which means passing in the flag:
-DH5_USE_16_API
to the h5cc command line like:
h5cc -DH5_USE_16_API ./example1.c
and it should compile correctly; otherwise you will have to rewrite the code to make use of the 1.8 API.

Resources