I have some js files that are in UTF-8 BOM encoding. I want to convert these files to UTF-8 encoding using ant. I used copy task of ant for this
<copy todir="./custom_plugins" overwrite="true" outputencoding="UTF-8">
<fileset dir="../plugins" />
</copy>
Now when I open a file that was in UTF-8 BOM in notepad++ it shows its encoding in ANSI format but this also appends the  character at the beginning of the file.
Even i tried this, but not working.
How can I solve this?
After encoding these files to UTF-8 I used replaceregexp ant task to remove/replace BOM character \xEF\xBB\xBF with empty string.
<replaceregexp match="\xEF\xBB\xBF" replace="" byline="true" encoding="UTF-8">
<fileset dir="./custom_plugins">
<include name="**/*.js"/>
</fileset>
</replaceregexp>
Related
I have a big load of .properties files in multi-languages, some contain unicode escaped formatting (\u304B\u3089). I'm interested in decoding all all of the files to non-escaped utf-8 chars ( から). I was thinking about using the native2ascii task reverse option in ANT, and I used this code for the build.xml:
<project>
<target name= "test">
<native2ascii reverse="true" encoding="utf-8" src="build/test" dest="build/test/1"/>
</target>
</project>
Problem is that the files are mixed, some have escaped-unicode and some show the proper chars. As a result of running this build with ANT, the ones that were proper are now distorted. How can I modify the code so it will only run on the files which have unicode-escaped? (I was thinking about a condition which modifies only files which contain "\u", but I was not able to achieve this)
Try using the copy task, setting the source encoding and destination encoding to UTF-8:
<copy file="input.properties" tofile="output.properties" overwrite="true"
encoding="UTF-8" outputencoding="UTF-8" />
I wrote a script in Phing that copies files for two websites, but I can't do such thing like copy file with a name change. I want to copy this image into favicon.png.
<copy todir="C:\dest_folder\" >
<fileset dir="C:\source_folder\" >
<patternset>
<include name="assets/ico/favicon_website1.png"/>
</patternset>
</fileset>
</copy>
Can this be done in only one <copy> tag?
How can I do it?
I expect quite a few files to be copied with a changed name so I want to simplify the script.
If it's just the one file you want to rename, use tofile rather than a fileset.
<copy file="assets/ico/favicon_website1.png" tofile="C:\dest_folder\favicon.png" />
I have a few hundred textile files in my eclipse project and I have written an ant-build xml file for creating the output html files. This works fine normally. However, every time I add some .textile files to the project, I also have to edit the projectBuilder.xml file manually if the the output has to be generated.
Is there a way in eclipse where I can generate the projectBuilder.xml file automatically? i.e. Lets say, I add a new folder with some 50 subfolders having .textile files inside them, I want eclipse to detect this and add those paths to the build file.
Following is part of the build file for illustration purpose:
<?xml version="1.0"?>
<project name="ALM" default="generate-html">
<property name="wikitext.standalone" value="jar" />
<path id="wikitext.classpath">
<fileset dir="${wikitext.standalone}">
<include name="org.eclipse.mylyn.wikitext.*core*.jar" />
</fileset>
</path>
<taskdef classpathref="wikitext.classpath" resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties" />
<target name="generate-html" description="Generate HTML from textile source">
<wikitext-to-html markupLanguage="Textile">
<fileset dir="${basedir}/..">
<include name="Docu/*.textile" />
<include name="Add-Ons/*.textile" />
<include name="uC1/asv/ASD/doc/*.textile" />
I'm not sure, which of these 2 problems you have.
To automate the transformation process, select Project->Properties->Builder. Add an Ant builder and give it the Ant script that you already have. This leads to running your script on every change in the project (like the normal Java compiler). If you want to run the Ant script only when your textile files change, then have a look at the last tab "Build options" when configuring that builder, there you can restrict it to a "working set of relevant resources".
To dynamically get the list of directories, there are multiple ant tasks available and it might depend on your project layout what to use: Using fileset you could just find all textile files and then use the fileset contents for the generation: Find all directories in which a file exists, such that the file contains a search string Or if the directory structure very plain, then you can just iterate it with foreach: Ant: How do I interate over all subfolders and perform a task in ant.
I am developing in eclipse websites in php.
I want to create a build configuration using Ant, to copy files from the project folder to a specific output path.
How is this possible using eclipse builders?
Ant copy task: http://ant.apache.org/manual/Tasks/copy.html
Example which copies one file to another:
<!-- copy file -->
<copy file="./service.jar" tofile="./service-v1.jar" overwrite="true"/>
Example which copies all XML, PNG, and JSON files from one directory to another, maintaining folder structure:
<!-- copy files -->
<copy todir="./destination">
<fileset dir="./src">
<include name="**/*.xml"/>
<include name="**/*.png"/>
<include name="**/*.json"/>
</fileset>
</copy>
As part of the Nant copy task, I would like to change the properties of the files in the target location. For instance make the files "read-write" from "read-only". How would I do this?
Use the <attrib> task. For example, to make the file "test.txt" read/write, you would use
<attrib file="test.txt" readonly="false"/>
Also, for a list of files, the command is:
<attrib readonly="false">
<fileset basedir="mydirectory">
<include name="**"/>
</fileset>
</attrib>