我有一个Maven项目,它构建了Apache solr-core库的补丁版本。第一步是解压缩原始源代码:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>solr-core-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>${solr.version}</version>
<type>jar</type>
<classifier>sources</classifier>
<outputDirectory>${solr.sources.dir}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
问题是,在某些平台上,源代码无法读取,权限为070(——rwx——)。例如,它在Linux构建服务器上很好(perms是644),但是在开发人员的Windows 7机器之间的行为不一致,每个机器都在Cygwin和umask 0022下。
我想在解包后添加一个步骤来chmod源代码:有办法做到这一点吗?我尝试了依赖插件的ignorePermissions和useJvmChmod的排列,但没有成功。我知道汇编插件支持chmod操作,但显然不像我在这里想的那样就地进行,而且我还遇到了使用ant的笨拙解决方案。有什么想法或建议吗?谢谢!
您可以使用antrun插件在解压缩文件后运行chmod:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>build</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>run chmod in ${basedir}</echo>
<chmod file="${project.basedir}/filepattern.txt" perm="ugo+rx"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
ant chmod Task通常不会在普通窗口上做任何事情(它不会导致构建失败)。