You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Néstor Boscán <ne...@gmail.com> on 2015/08/25 22:01:13 UTC

Problems compiling source java with different encodings

Hi

I have a legacy code that compiles correctly using IDEA or JDeveloper. But
if I try to use maven compile it generates error because there are unknoen
characters in the comments. It looks like the legacy code has different
types of character encoding in the file. Is there a way to compile using
maven that will not take into consideration the comments?

Regards,

Néstor

Re: Problems compiling source java with different encodings

Posted by Hervé BOUTEMY <he...@free.fr>.
maven-compiler-plugin by default uses JDK's javac: it seems javac can't work 
with the encoding soup you have in legacy code. If you find some feature in 
javac to deal with that problem, you'll have to see how to inject the trick 
into maven-compiler-plugin
because Maven, or more precisely maven-compiler-plugin, can't "fix" the 
compiler, or more precisely not "fix" since it's not a compiler bug, but add a 
feature to the compiler to support weird source code


You really should fix your encoding soup problem: I suppose you know it :)
because you'll find at every level: how do your developer work with their IDE 
to edit the code? Do they choose to be able to see/update Strings or comments?
Perhaps the legacy code is really dead, so you can avoid this IDE problem...


If you can't fix the real problem nor find javac option to support it, another 
workaround I see could be to make maven-compiler-plugin not use javac but use 
a compiler that supports the encoding soup: I never used this feature myself, 
but here is the maven-compiler-plugin doc [1]


Regards,

Hervé


[1] http://maven.apache.org/plugins/maven-compiler-plugin/non-javac-compilers.html

Le mardi 25 août 2015 17:04:05 Néstor Boscán a écrit :
> Yes,
> 
> The problem is that the legacy code has comments in Cp1252 and Strings in
> UTF-8. The weird thing is that IDEA and JDeveloper can compile them using
> their internal compilers.
> 
> Regards,
> 
> Néstor
> 
> On Tue, Aug 25, 2015 at 3:36 PM, Russell Gold <ru...@oracle.com>
> 
> wrote:
> > Do you have the following in your pom.xml?
> > 
> >     <properties>
> >     
> >         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >     
> >     </properties>
> > 
> > If not, do you know what encoding is being used in your source file?
> > 
> > > On Aug 25, 2015, at 4:01 PM, Néstor Boscán <ne...@gmail.com> wrote:
> > > 
> > > Hi
> > > 
> > > I have a legacy code that compiles correctly using IDEA or JDeveloper.
> > 
> > But
> > 
> > > if I try to use maven compile it generates error because there are
> > 
> > unknoen
> > 
> > > characters in the comments. It looks like the legacy code has different
> > > types of character encoding in the file. Is there a way to compile using
> > > maven that will not take into consideration the comments?
> > > 
> > > Regards,
> > > 
> > > Néstor
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Problems compiling source java with different encodings

Posted by Néstor Boscán <ne...@gmail.com>.
Yes,

The problem is that the legacy code has comments in Cp1252 and Strings in
UTF-8. The weird thing is that IDEA and JDeveloper can compile them using
their internal compilers.

Regards,

Néstor

On Tue, Aug 25, 2015 at 3:36 PM, Russell Gold <ru...@oracle.com>
wrote:

> Do you have the following in your pom.xml?
>
>     <properties>
>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>     </properties>
>
> If not, do you know what encoding is being used in your source file?
>
>
> > On Aug 25, 2015, at 4:01 PM, Néstor Boscán <ne...@gmail.com> wrote:
> >
> > Hi
> >
> > I have a legacy code that compiles correctly using IDEA or JDeveloper.
> But
> > if I try to use maven compile it generates error because there are
> unknoen
> > characters in the comments. It looks like the legacy code has different
> > types of character encoding in the file. Is there a way to compile using
> > maven that will not take into consideration the comments?
> >
> > Regards,
> >
> > Néstor
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Problems compiling source java with different encodings

Posted by Russell Gold <ru...@oracle.com>.
Do you have the following in your pom.xml?

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

If not, do you know what encoding is being used in your source file?


> On Aug 25, 2015, at 4:01 PM, Néstor Boscán <ne...@gmail.com> wrote:
> 
> Hi
> 
> I have a legacy code that compiles correctly using IDEA or JDeveloper. But
> if I try to use maven compile it generates error because there are unknoen
> characters in the comments. It looks like the legacy code has different
> types of character encoding in the file. Is there a way to compile using
> maven that will not take into consideration the comments?
> 
> Regards,
> 
> Néstor


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org