Dan*_*tes 16 java maven-2 dos2unix
我有一个在Windows环境中开发的应用程序.应用程序本身部署到Linux环境.每次部署此应用程序时,我都必须使用dos2unix将可执行文件转换为UNIX格式.我原本以为这是由Windows CP1252编码引起的,所以我更新了Maven将文件编码为UTF-8.这并没有解决我的问题,我很快发现这与回车和换行有关,可以通过搜索这个站点来解决.有没有办法让Maven在构建过程中将所有文件转换为UNIX格式?我正在使用Maven 2.2.1和Java 5.
Pas*_*ent 42
程序集插件有一个lineEnding选项,可用于控制给定文件的行尾fileSet.这个参数正好可以做你想要的.最终,您可以使用CRLF行构建zip存档,使用LF行构建tar.gz存档.
例如
...
<fileSet>
<directory>${basedir}/src/main/build/QA</directory>
<outputDirectory>/bin</outputDirectory>
<includes>
<include>start.sh</include>
</includes>
<lineEnding>unix</lineEnding>
</fileSet>
...
Run Code Online (Sandbox Code Playgroud)
此时可能的值包括:
Kev*_*vin 16
您可以使用Maven antrun插件来调用fixcrlf ant任务:
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18206 次 |
| 最近记录: |