maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Baptiste MATHUS ...@batmat.net>
Subject Re: Validate html encoding with maven in webapp project
Date Mon, 22 Jul 2013 09:54:05 GMT
Hi,
Validating an encoding is actually more complex than it seems. Basically,
it's about validating some bytes (or bytes sequences in utf-8). It's not
feasible apart from using some heuristics (meaning, ok you're using a
brasil locale, so I'm gonna look for weird byte combinations, but no 100%
sure I'm not gonna trigger false positives).

I don't know of a tool that would do that in maven. But if you find any
tool or lib that satisfies you then I suppose that one could be integrated
as an enforcer rule.

Hth.
Cheers
Le 22 juil. 2013 07:42, "Maximiliano Milicich" <
maximilianomilicich@gmail.com> a écrit :

> Let me put it this way:
> If I take one java Class of my project, I add some latin characters like á
> é í ó ú ñ (we use it a lot in spanish writing), and I save this *.java file
> choosing in IDE editor options ANSI encoding instead of UTF8 encoding, then
> when I invoke maven compiling:
> $ mvn clean package
> I get this BUILD FAILURE message:
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
> (default-compile) on project xyz: Com
> pilation failure: Compilation failure:
> [ERROR]
> /usr/home/xyz/src/main/java/ar/com/xyz/pdf/SeamPdfDocument.java:[35,95]
> unmappable character for encoding UTF-8
>
> This is, as far as i know, because of having this setting
>  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> in my POM's properties.
>
> Could I achieve the same validation but with my *.html files content?
>
> I mean, If I open xyz.html and I add the following line
> <p>these are latin problematic characters: á é í ó ú ñ Ñ </p>
> I save file with ANSI encoding instead of UTF-8
> Could I get Maven give me some warning about this?
>
> Thanks againg
> Max from Buenos Aires, Argentina
>
>
>
>
>
> On Mon, Jul 22, 2013 at 2:08 AM, Russell Gold <russ@gold-family.us> wrote:
>
> > What would validation consist of? How would you determine that
> > interpreting the file as UTF-8 would produce the correct view?
> >
> > It seems to me that if you can actually decide what the rules are that
> you
> > could write a test for it. But I cannot imagine any general automatic way
> > to do it, as a matter of principle.
> >
> > - Russ
> >
> > On Jul 22, 2013, at 12:56 AM, Maximiliano Milicich <
> > maximilianomilicich@gmail.com> wrote:
> >
> > > Hello:
> > > Is it posible to get Maven validate html encoding in a webapp project
> at
> > > compile time?
> > >
> > > Sometimes developers make mistakes and save files with wrong encoding,
> > and
> > > this error appears only when the webapp is deployed onto the web
> server.
> > >
> > > I've tried so far with "maven-resource-plugin" with this section:
> > >   <build>
> > >      <plugins>
> > >         <plugin>
> > >           <groupId>org.apache.maven.plugins</groupId>
> > >           <artifactId>maven-resources-plugin</artifactId>
> > >           <version>2.6</version>
> > >           <configuration>
> > >             <encoding>UTF-8</encoding>
> > >           </configuration>
> > >         </plugin>
> > >      </plugins>
> > >  </build>
> > >
> > > But it makes nothing...it packages my webapp project even with html
> with
> > > wrong encoding.
> > >
> > > I'm using Maven 3.0.5
> > > Thanx in advance
> > > Max from Buenos Aires, Argentina
> >
> > -----------------
> > Come read my webnovel, Take a Lemon <http://www.takealemon.com>,
> > and listen to the Misfile radio play <
> > http://www.gold-family.us/audio/misfile.html>!
> >
> >
> >
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message