You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jeffrey Walton <no...@gmail.com> on 2015/02/17 21:11:58 UTC
Specify source file language in build.xml?
I'm trying to build an Android project from the command line. I'm
getting an error during `ant release`. The error is unmappable
character for encoding UTF-8.
The sources appear to be written by a non-English speaker, and the
offending characters are in comments like so:
/*
* Projet : Permission Explorer
* Auteur : Carlo Criniti
* Date : 2011.06.10
*
* Classe ApplicationDetail
* ActivitÈ d'affichage du dÈtail d'une application
* avec les permissions qu'elle utilise
*/
There are multiple errors like this. If /usr/local/bin/ant release
2>&1 | grep -i error | wc -l is accurate, then there's 103 of them.
I've been through ant's documentation at "Writing a Simple Buildfile"
(http://ant.apache.org/manual/using.html) and "Property Task"
(http://ant.apache.org/manual/Tasks/property.html), but damn if I can
figure out how to set a source file language to get past these errors.
How do I specify a source file language in build.xml?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Specify source file language in build.xml?
Posted by "Bickford, Mark" <Ma...@wexinc.com>.
In my experience with Android, you can create an ant.properties which will be read at the start of the build, and you should be able to set the java.encoding property there.
So far as the error itself goes, it came in with Java 7; I had source files with Microsoft smart quotes in the comments that had to be repaired before they would compile.
-----Original Message-----
From: Peter West [mailto:lists@pbw.id.au]
Sent: February 17, 2015 7:24 PM
To: Ant Users List; noloader@gmail.com
Subject: Re: Specify source file language in build.xml?
Are you able to modify the files? iconv (on a unix-based system) will convert encodings. Ideally, the files should be utf-8 encoded. You can use iconv to try out suspected encodings for the files, by converting from what you think may be the encoding to utf-8, and having a look. Once you've worked out the encoding, you can bulk convert the files, or just bulk convert and copy to a working directory, and build from there.
I assume these files were created on a windows system?
Peter West
And they ate, and were satisfied...
> On 18 Feb 2015, at 7:35 am, Jeffrey Walton <no...@gmail.com> wrote:
>
> On Tue, Feb 17, 2015 at 4:26 PM, Earl Hood <ea...@gmail.com> wrote:
>> On Tue, Feb 17, 2015 at 2:58 PM, Jeffrey Walton wrote:
>>
>>>> Use the 'encoding' attribute to the <javac> task.
>> ...
>>> <javac encoding="${java.encoding}"
>>> source="${java.source}" target="${java.target}"
>>> debug="true" extdirs="" includeantruntime="false"
>>> destdir="${out.classes.absolute.dir}"
>>> bootclasspathref="project.target.class.path"
>>> verbose="${verbose}"
>>> classpathref="project.javac.classpath"
>>> fork="${need.javac.fork}">
>>> <src path="${source.absolute.dir}" />
>>> <src path="${gen.absolute.dir}" />
>>> <compilerarg line="${java.compilerargs}" />
>>> </javac>
>>
>> I do not know the specifics of how your build files are organized and if
>> you are using <ant> tasks to call other build files or you are including
>> all the build files so that targets are available directly.
>>
>> With the fragment above, you need to set the java.encoding property.
>> You can do this from the command-line:
>>
>> ant -Djava.encoding=UTF-8 ...
>
> That's what I was looking for! My dumb ass tried the following:
>
> $ /usr/local/bin/ant "java.encoding=ascii" release
> Buildfile: /Users/android-permission-explorer/build.xml
>
> BUILD FAILED
> Target "encoding=ascii" does not exist in the project "Permission Explorer".
>
>> Command-line property settings have the highest precedence and will
>> override any setting in the build files.
>> ...
>>
>> Note, java.encoding is not a default java system property, so something
>> is setting the property before the <javac> task is invoked.
>
> Yeah, I'm beginning to think this is an Android problem.
>
> Thanks for the help. Now that I have an idea of what I should do, I
> think I should pursue it on an Android list.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Specify source file language in build.xml?
Posted by Peter West <li...@pbw.id.au>.
Are you able to modify the files? iconv (on a unix-based system) will convert encodings. Ideally, the files should be utf-8 encoded. You can use iconv to try out suspected encodings for the files, by converting from what you think may be the encoding to utf-8, and having a look. Once you've worked out the encoding, you can bulk convert the files, or just bulk convert and copy to a working directory, and build from there.
I assume these files were created on a windows system?
Peter West
And they ate, and were satisfied...
> On 18 Feb 2015, at 7:35 am, Jeffrey Walton <no...@gmail.com> wrote:
>
> On Tue, Feb 17, 2015 at 4:26 PM, Earl Hood <ea...@gmail.com> wrote:
>> On Tue, Feb 17, 2015 at 2:58 PM, Jeffrey Walton wrote:
>>
>>>> Use the 'encoding' attribute to the <javac> task.
>> ...
>>> <javac encoding="${java.encoding}"
>>> source="${java.source}" target="${java.target}"
>>> debug="true" extdirs="" includeantruntime="false"
>>> destdir="${out.classes.absolute.dir}"
>>> bootclasspathref="project.target.class.path"
>>> verbose="${verbose}"
>>> classpathref="project.javac.classpath"
>>> fork="${need.javac.fork}">
>>> <src path="${source.absolute.dir}" />
>>> <src path="${gen.absolute.dir}" />
>>> <compilerarg line="${java.compilerargs}" />
>>> </javac>
>>
>> I do not know the specifics of how your build files are organized and if
>> you are using <ant> tasks to call other build files or you are including
>> all the build files so that targets are available directly.
>>
>> With the fragment above, you need to set the java.encoding property.
>> You can do this from the command-line:
>>
>> ant -Djava.encoding=UTF-8 ...
>
> That's what I was looking for! My dumb ass tried the following:
>
> $ /usr/local/bin/ant "java.encoding=ascii" release
> Buildfile: /Users/android-permission-explorer/build.xml
>
> BUILD FAILED
> Target "encoding=ascii" does not exist in the project "Permission Explorer".
>
>> Command-line property settings have the highest precedence and will
>> override any setting in the build files.
>> ...
>>
>> Note, java.encoding is not a default java system property, so something
>> is setting the property before the <javac> task is invoked.
>
> Yeah, I'm beginning to think this is an Android problem.
>
> Thanks for the help. Now that I have an idea of what I should do, I
> think I should pursue it on an Android list.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Specify source file language in build.xml?
Posted by Jeffrey Walton <no...@gmail.com>.
On Tue, Feb 17, 2015 at 4:26 PM, Earl Hood <ea...@gmail.com> wrote:
> On Tue, Feb 17, 2015 at 2:58 PM, Jeffrey Walton wrote:
>
>>> Use the 'encoding' attribute to the <javac> task.
> ...
>> <javac encoding="${java.encoding}"
>> source="${java.source}" target="${java.target}"
>> debug="true" extdirs="" includeantruntime="false"
>> destdir="${out.classes.absolute.dir}"
>> bootclasspathref="project.target.class.path"
>> verbose="${verbose}"
>> classpathref="project.javac.classpath"
>> fork="${need.javac.fork}">
>> <src path="${source.absolute.dir}" />
>> <src path="${gen.absolute.dir}" />
>> <compilerarg line="${java.compilerargs}" />
>> </javac>
>
> I do not know the specifics of how your build files are organized and if
> you are using <ant> tasks to call other build files or you are including
> all the build files so that targets are available directly.
>
> With the fragment above, you need to set the java.encoding property.
> You can do this from the command-line:
>
> ant -Djava.encoding=UTF-8 ...
That's what I was looking for! My dumb ass tried the following:
$ /usr/local/bin/ant "java.encoding=ascii" release
Buildfile: /Users/android-permission-explorer/build.xml
BUILD FAILED
Target "encoding=ascii" does not exist in the project "Permission Explorer".
> Command-line property settings have the highest precedence and will
> override any setting in the build files.
> ...
>
> Note, java.encoding is not a default java system property, so something
> is setting the property before the <javac> task is invoked.
Yeah, I'm beginning to think this is an Android problem.
Thanks for the help. Now that I have an idea of what I should do, I
think I should pursue it on an Android list.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Specify source file language in build.xml?
Posted by Earl Hood <ea...@gmail.com>.
On Tue, Feb 17, 2015 at 2:58 PM, Jeffrey Walton wrote:
>> Use the 'encoding' attribute to the <javac> task.
...
> <javac encoding="${java.encoding}"
> source="${java.source}" target="${java.target}"
> debug="true" extdirs="" includeantruntime="false"
> destdir="${out.classes.absolute.dir}"
> bootclasspathref="project.target.class.path"
> verbose="${verbose}"
> classpathref="project.javac.classpath"
> fork="${need.javac.fork}">
> <src path="${source.absolute.dir}" />
> <src path="${gen.absolute.dir}" />
> <compilerarg line="${java.compilerargs}" />
> </javac>
I do not know the specifics of how your build files are organized and if
you are using <ant> tasks to call other build files or you are including
all the build files so that targets are available directly.
With the fragment above, you need to set the java.encoding property.
You can do this from the command-line:
ant -Djava.encoding=UTF-8 ...
Command-line property settings have the highest precedence and will
override any setting in the build files.
If you are using <ant> and/or <antcall>, both tasks allow you to
specify property settings for the target(s) you invoke (see the
documentation).
> <project>
> ...
> <property name="java.encoding" value="ascii" />
> </project>
If you know the source files are using UTF-8, then use "UTF-8" as the
encoding.
Note, java.encoding is not a default java system property, so something
is setting the property before the <javac> task is invoked.
--ewh
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Specify source file language in build.xml?
Posted by Jeffrey Walton <no...@gmail.com>.
On Tue, Feb 17, 2015 at 3:17 PM, Earl Hood <ea...@gmail.com> wrote:
> On Tue, Feb 17, 2015 at 2:11 PM, Jeffrey Walton wrote:
>> I'm trying to build an Android project from the command line. I'm
>> getting an error during `ant release`. The error is unmappable
>> character for encoding UTF-8.
>
> Use the 'encoding' attribute to the <javac> task.
Thanks Eric.
It looks like build.xml brings in
$ANDROID_SDK_ROOT/tools/ant/build.xml, and Android's build.xml uses
{java.encoding}:
$ cat "$ANDROID_SDK_ROOT/tools/ant/build.xml" | grep -A 10 javac
...
<javac encoding="${java.encoding}"
source="${java.source}" target="${java.target}"
debug="true" extdirs="" includeantruntime="false"
destdir="${out.classes.absolute.dir}"
bootclasspathref="project.target.class.path"
verbose="${verbose}"
classpathref="project.javac.classpath"
fork="${need.javac.fork}">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<compilerarg line="${java.compilerargs}" />
</javac>
I tried adding the following to the project's build.xml (not Android's
build.xml), but with no joy. It results in same/similar errors:
<project>
...
<property name="java.encoding" value="ascii" />
</project>
I also tried to add the following to the project's build.xml (not
Android's build.xml):
<project>
...
<javac encoding="ascii" />
</project>
But it results in:
build.xml:115: srcdir attribute must be set!
I know ASCII is probably wrong. I'm just trying to get a toehold on
the fix at the moment).
How, exactly, do I specify the 'encoding' attribute to the <javac> task?
Sorry to ask. I'm not sure where the delineation between Ant problems
and Android problems occurs (should I be asking on an Android list?).
And all of this is modulo the problem of me being inexperienced and
wondering why comments are not being ignored (ignoring comments would
make this a non-sequitur).
Jeff
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Specify source file language in build.xml?
Posted by Earl Hood <ea...@gmail.com>.
On Tue, Feb 17, 2015 at 2:11 PM, Jeffrey Walton wrote:
> I'm trying to build an Android project from the command line. I'm
> getting an error during `ant release`. The error is unmappable
> character for encoding UTF-8.
Use the 'encoding' attribute to the <javac> task.
--ewh
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org