I'm using OpenLiberty (automatically downloaded through its maven plugin) and my application is working fine (jax-rs and servlet/jsp outputs are fine).
But the console (and messages.log) output is messy. Here is one example:
[INFORMAıåES] SRVE0253I: [io.openliberty.microprofile.health.3.0.internal] [/health] [HealthCheckServlet]: Destrui?Æo bem sucedida.
(expected is [INFORMAÇÕES] ... Destruição bem sucedida.)
Clearly the messages are being printed as ISO-8859-1 in a UTF-8 capable terminal.
Again, this question is not about the application running inside OpenLiberty container, which is completely UTF-8 and working fine. It is about the console output.
A partially useful workaround would be to change its locale to en-US (so that OpenLiberty's messages wouldn't need any special character). Actually, I'd prefer english error messages, because they are easier to google for.
I already tried LANG=en-US.UTF8, LC_ALL=en_US and LC_MESSAGES=en_US, to no avail.
Project's effective pom.xml already declares <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>. Every file in my project is UTF-8. Project's .editorconfig [*] charset = utf-8 (so vscode creates every new file as utf-8).
I'm using bash MINGW64_NT-10.0-18363 + ConEmu-Maximus5 over Windows 10. LANG defaults to =pt_BR.UTF-8.
UPDATE
I've managed to set locale to en-US by adding
-Duser.language=en to ${server.config.dir}/jvm.options.
To be honest, I did it through liberty-maven-plugin:
<properties>
...
<liberty.jvm.language>-Duser.language=en-US</liberty.jvm.language>
...
</properties>
(and for liberty-maven-plugin itself, I've added -Duser.language=en to MAVEN_OPTS)
Unfortunately, -Dfile.encoding=UTF-8 did nothing.
UPDATE 2
I'm also running OpenLiberty inside an Arquillian driven junit test. Interestingly, when launched by arquillian, OpenLiberty honors the -Dfile.encoding=utf-8 setting.
For arquillian it could be configured through arquillian.xml:
<arquillian ...>
<container qualifier="liberty_managed" default="true">
<configuration>
...
<property name="javaVmArguments">-Dfile.encoding=utf-8</property>
...
</configuration>
</container>
</arquillian>
Or in ${server.config.dir}/jvm.options (as I did before):
-Dfile.encoding=utf-8
My conclusion is that -Dfile.encoding is the right way to approach this issue. But somehow when launched by liberty-maven-plugin it is not honored. I'll take a closer look into its source code.
UPDATED ANSWER: This is configurable via JVM options.
Note that in general the jvm.options file requires you to use a single option per line.
If want to use multiple options and use liberty-maven-plugin properties to configure them you could do something like:
<properties>
<liberty.jvm.arg1>-Duser.language=pt</liberty.jvm.arg1>
<liberty.jvm.arg2>-Duser.country=BR</liberty.jvm.arg2>
<liberty.jvm.arg3>-Dfile.encoding=utf-8</liberty.jvm.arg3>
</properties>
(Note that the arg1,arg2,arg3 suffixes don't really get used except to assign unique Maven project property names, but don't appear in the jvm.options file).
And your terminal program must have support for displaying these characters. E.g. for me using the Git Bash default terminal with default settings on a US/English install, the characters in the above Portuguese language config don't display unless click the Window icon then "Options" and add this:
Related
SUMMARY
How can I iteratively run my unit/integration tests in "dev mode" of the liberty-maven-plugin and easily turn on and off the launching of the debugger into the JVM running the tests themselves?
BACKGROUND
While the liberty-maven-plugin by default starts the Open Liberty server in debug mode, sometimes you need to debug into the source of the unit/integration tests themselves. The liberty-maven-plugin dev mode launches the server and will (by default) run my tests each time I hit <Enter>.
I can leverage standard documented approaches, which by default will launch a forked JVM waiting for a debugger on port 5005, e.g.:
mvn -Dmaven.failsafe.debug liberty:dev
But what if I already started dev mode without that property set on the command line?
Is there an easy way to enable the debugger after the fact? Or to toggle it on/off across executions?
An easy way to "toggle" the debug mode for the tests is to use Maven project properties and dynamically comment/uncomment out the standard test debug properties, e.g. maven.failsafe.debug.
E.g this will launch ITs in a forked JVM, suspended and waiting for the debugger on port 5005:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.failsafe.debug>true</maven.failsafe.debug>
<!--
<maven.surefire.debug>true</maven.surefire.debug>
-->
</properties>
You can also configure the maven-failsafe-plugin in your pom.xml with normal plugin configuration to configure non-default behavior.
This should work with recent (since v3.1) versions of the liberty-maven-plugin, e.g.:
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.3.3</version>
</plugin>
This could be applied to a simple sample app like the one here:
https://openliberty.io/guides/getting-started.html
WARNING
Don't make the mistake of toggling the value to "false" since you're really configuring this parameter. Just comment it out completely to avoid suspending for the debugger.
I am using Ant to build a self deploying EXE for a JavaFX application.
Currently Inno Setup places the EXE here: C:\Users\username\AppData\Local\application name
I would like to place this in a different location, and provide the user the option to override this. However I can't seem to find the ant settings to change this.
Is this possible?
Thanks!
Actually you can't change this using ANT. However, as you already know the deploy mechanism uses Inno Setup and you can modify its behaviour.
During the fx:deploy ANT task a default ApplicationName.iss file is created. This default file contains e.g. the setting, which is responsible for the install directory. This default file is only created, if you don't provide any customized on your own. So, I would recommend to run the ANT script, copy the default file and modify it. If you enable the verbose flag of the fx:deploy task you can use the console output to find out, where the default file is created and where the ANT task searches for your customized file before creating the default one:
<fx:deploy
...
verbose="true">
<fx:info title="${appname}" vendor="${vendor}"/>
...
</fx:deploy>
In my case I found the default file in
C:\Users\gfkri\AppData\Local\Temp\fxbundler3627681647438085792\windows
and had to put the customized file to
package/windows/ApplicationName.iss
relative to the ANT build script.
If you got so far, you'll find the line DisableDirPage=Yes in your ApplicationName.iss file. Change it to DisableDirPage=No and the user gets the possibility to change the install directory.
Further you will find the parameter DefaultDirName. If you want to install your Application to C:\Program File\ApplicationName by default you can use the constant {pf} e.g.: DefaultDirName={pf}\ApplicationName.
The original answer is not true anymore, because that feature got added to the JDK (just dont know when, but it was there when using 1.8.0u60 or so).
Just add <installdirChooser> as some <bundleArguments> and set it to true:
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.4.0</version>
<configuration>
<mainClass>your.mainclass</mainClass>
<verbose>true</verbose>
<bundleArguments>
<identifier>SOME-GUID-USED-FOR-UPDATE-DETECTION</identifier>
<installdirChooser>true</installdirChooser>
</bundleArguments>
</configuration>
</plugin>
Disclaimer: I'm the maintainer of the javafx-maven-plugin
I need get feature scenarios without running tests with maven via cmd. Cucumber has 'dryRun' option. But don`t know how to add this option to pom.xml. I tried many variants, but it not helped.
Type in cmd:
mvn verify -Dfeature=Forum.feature -DdryRun=false
but I got error. -DdryRun options does not works.
Please take a look screenshot http://imgur.com/6p11Y6V
According to your screenshot you have the following configuration:
<systemPropertyVariables>
<cucumber.options>
<![CDATA[--tags ${tags} ${dryRun} [${cucumber.features.dir}/${feature}]]>
</cucumber.options>
</systemPropertyVariables>
This would insert true or false into the environment variable, which is not a valid option and instead gets interpreted as a path to a feature file.
Cucumber instead expects a parameter like --dry-run or --no-dry-run (https://github.com/cucumber/cucumber-jvm/blob/v1.2.0/core/src/main/java/cucumber/runtime/RuntimeOptions.java#L116). The solution would be to define your property like this:
<properties>
<dryRun>--dry-run</dryRun>
</properties>
Unrelated to that, the opening brace before the feature path would also cause cucumber not to find the feature.
Here's my scenario:
Maven 2.0.9 is our build system
We install code to multiple environments
All of our environment-specific properties are contained in property files, one for each environment
We currently read these properties into maven using the properties-maven-plugin; this sub-bullet is not a requirement, just our current solution
Goal:
Perform certain parts of the build (ie. plugin executions) only for certain environments
Control which parts are run by setting values in the environment-specific property files
What I've tried so far:
Maven allows plugins executions to be put inside pom profiles, which can be activated by properties; unfortunately these must be system properties - ie. from settings.xml or the command-line, not from properties loaded by the properties-maven-plugin
If possible, we'd like to keep everything encapsulated within the build workspace, which looks something like this:
project
pom.xml
src
...
conf
dev.properties
test.properties
prod.properties
build-scripts
build.groovy <-- the script that wraps maven to do the build
install.groovy <-- ... wraps maven to do the install
Running a build looks like:
cd build-scripts
./build.groovy
./install.groovy -e prod
Is there any possible way to accomplish these goals with the version of maven we are using? If not, is it possible with a newer version of maven?
This isn't possible using just Maven. (See also How to activate profile by means of maven property?) The reason is that profiles are the first thing evaluated before anything else to determine the effective POM.
My suggestion is to write some preprocessor that parses your environment specific property files and converts them to the required system properties before launching Maven. This script can be included in your ~/.mavenrc so that it runs automatically before Maven is launched. Here is an example script that that assumes the properties file is in a fixed location:
properties=`cat /etc/build-env.properties`
while read line; do
MAVEN_OPTS="$MAVEN_OPTS -D$line"
done <<< "$properties"
If the properties file is not fixed, you'll just need to add something to the script to discover the location (assuming it is discoverable).
I've created a svn repositoy on a linux server (Debian) and used a client on a windows machine to check my java sources in.
Now I've set up a Hudson server on a different linux server (Ubuntu) to periodically run tests on my code. But the tests fail with a compiler error:
Error: unmappable character for encoding ASCII
On my windows machine I've used the default encoding Cp1252.
On my svn server I can do a local checkout of my sources and they look good.
On my Hudson server the checkout contains illegal characters.
What are the parameters I have to adjust so that all three systems use a working encoding?
EDIT 2009-10-15:
I changed the default encoding of my Ubuntu system to latin1. Now I can open the checkedout files with an editor and they look good (thanks to #John-T at superuser.com).
But Hudson still complained about unmappable character for encoding ASCII and I found that this is caused by maven. I found an explantion, but the suggested solution didn't work. Now maven tells me that it uses latin1 when copying some resources, but the compiler (not using this setting?) still complains with the same error message.
No, the maven compiler plugin doesn't use the project.build.sourceEncoding property. So you need to configure the file encoding for it (I'd use UTF-8):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
The first thing to identify is which character is causing the problem. It may be that the broken char can be replaced by some pure-ASCII entity. SVN itself is encoding agnostic: it'll just store byte-for-byte what's passed in.
If Hudson requires 7-bit ASCII, then this is all you can do. Otherwise, find out what Hudson supports and save your files in this format instead. UTF-8 would probaby be the way to go.
I don't think there is a way to change the encoding of a file with SVN. You can set the encoding for a commit message with the --encoding flag, but not the contents of files themselves. Text files are stored in the same format they appear on your local disk. The only conversion is a translation of line endings according to the svn:eol-style property.