使用Maven将文件转换为UNIX格式 [英] Convert files to UNIX format using Maven

查看:244
本文介绍了使用Maven将文件转换为UNIX格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Windows环境中开发的应用程序。应用程序本身部署到Linux环境。每次部署此应用程序时,我都必须使用dos2unix将可执行文件转换为UNIX格式。我原本以为这是由Windows CP1252编码引起的,所以我更新了Maven将文件编码为UTF-8。这并没有解决我的问题,我很快发现这与回车和换行有关,通过搜索这个网站。有没有办法让Maven在构建过程中将所有文件转换为UNIX格式?我正在使用Maven 2.2.1和Java 5.

I have an application that is developed in a Windows environment. The application itself gets deployed to a Linux environment. Each time I deploy this application I have to convert executable files to UNIX format using dos2unix. I originally thought this was caused by the Windows CP1252 encoding, so I updated Maven to encode the files to UTF-8. This didn't solve my issue and I quickly found out that this has to do with carriage returns and line feeds by searching this site. Is there a way to have Maven convert all of the files to UNIX format during the build process? I am using Maven 2.2.1 and Java 5.

推荐答案

您可以使用Maven antrun 插件调用 fixcrlf ant任务:

You can use the Maven antrun plugin to call the fixcrlf ant task:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>ant-test</groupId>
    <artifactId>ant-test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>ant-test</id>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <fixcrlf ... />
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

这篇关于使用Maven将文件转换为UNIX格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆