2

I have a Maven project which builds a patched version of the Apache solr-core library. The first step is to unpack the original sources:

        <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>

The problem is that on certain platforms, the sources come out unreadable, with permissions of 070 (---rwx---). E.g. it's fine on the Linux build server (perms are 644), but behaviour is inconsistent between developers' Windows 7 machines, each under Cygwin and with umask 0022.

I'd like to add a step after unpacking to chmod the sources: is there a way to do this? I experimented with permutations of the dependency plugin's ignorePermissions and useJvmChmod without success. I know that the assembly plugin supports chmod operations, but apparently not in-place as I'd like here, and I've also come across a heavy-handed solution using ant. Any ideas or recommendations? Thanks!

Richard
  • 143
  • 1
  • 10
  • The problem was with my Cygwin setup: the solution was to edit /etc/fstab as described here: http://stackoverflow.com/a/7082542/1312552 – Richard Aug 24 '15 at 10:02

1 Answers1

3

You can use the antrun plugin to run a chmod after unpacking the files:

    <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>

The ant chmod Task will usually not do anything on plain windows (it will not cause a build failure).

wemu
  • 7,952
  • 4
  • 30
  • 59
  • Thanks, I experimented with using the "attrib" task to change the permissions on Windows, but Cygwin always saw them as 070. It turned out that the problem was with my Cygwin config: see my comment to the original post. – Richard Aug 24 '15 at 10:01