Character encoding problem when using sqlFile

I am trying to read SQL files in liquibase using the sqlFile tag. The problem is that when I use the updateSQL command all the non latin characters are replaced by question marks.


  1.      
I use maven and configured the liquibase-maven-plugin as follows :
  1.            
                    org.liquibase
                    liquibase-maven-plugin
                   
                        src/main/resources/dbSharedTables/liquibase/liquibase.properties
                        EURES3
                       
                           
                                liquibase.databaseChangeLogTableName
                                X_DATABASECHANGELOG
                           
                           
                                liquibase.databaseChangeLogLockTableName
                                X_DATABASECHANGELOGLOCK
                           
                           
                                file.encoding
                                UTF-8
                           
                       
                   
Version of liquibase : 2.0.2

Does anybody have an idea of what’s going on ?

Thank you,

Cédric

I included the fix for maven in 3.0 based on Nathan

Hi all,

this is a quite boring issue, in addition it is very easy to fix directly the code.
Is there a specific process to submit patch?
The issue can be resolved with few lines of code. This is the fix for 3.0.0-rc3-SNAPSHOT:

In AbstractLiquibaseMojo.java add:
    /**
     * Flag to set the character encoding of the output file produced by Liquibase during the updateSQL phase.
     
     
@parameter expression="${liquibase.outputFileEncoding}"
     */
    protected String outputFileEncoding;


In LiquibaseUpdateSQL.java substitute:
 
line 68: outputWriter = new FileWriter(migrationSqlOutputFile);

with:
            if (outputFileEncoding==null) {
                getLog().warn(“Charser encoding not set! The created file will be system dependent!”);
                outputWriter = new FileWriter(migrationSqlOutputFile);
            }
            else {
                getLog().info(“Writing output file with [” + outputFileEncoding + “] file encoding.”);
                outputWriter = new BufferedWriter(new OutputStreamWriter(
                        new FileOutputStream(migrationSqlOutputFile), outputFileEncoding));
            }


These simple changes allow the user to specify the charset directly in the pom.xml:

           
                org.liquibase
                liquibase-maven-plugin
                3.0.0-rc3-SNAPSHOT
               
                    pathToLiquibaseFiles/liquibase.properties
                    UTF-8
               
           

Could you include it in the source of version 3.0?

Regards
Francesco Cina