0

我有下一个目录结构:

    src/main/resources/export/v1/android/
    src/main/resources/export/v1/ios/
    src/main/resources/export/v2/android/
    src/main/resources/export/v2/ios/
    ...
    src/main/resources/export/vn/android/
    src/main/resources/export/vn/ios/

我需要获得下一个结果:

    WEB-INF/export/v1/android.zip
    WEB-INF/export/v1/ios.zip
    WEB-INF/export/v2/android.zip
    WEB-INF/export/v2/ios.zip
    ...
    WEB-INF/export/vn/android.zip
    WEB-INF/export/vn/ios.zip

我可以用 maven-assembly-plugin 解决问题吗?如果没有,是否有另一个插件可以处理它,或者编写自定义类并使用 exec-maven-plugin 调用它更好?

4

2 回答 2

0

我最终编写了 java 类并使用exec-maven-plugin运行它,如下所示:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
        <id>Running custom java class</id>
        <phase>compile</phase>
        <goals><goal>java</goal></goals>
        <inherited>false</inherited>
        <configuration>
            <mainClass>mycompany.CustomJavaClass</mainClass>
            <classpathScope>compile</classpathScope>
            <arguments>
                <argument>
                  ${project.basedir}/src/main/resources/export
                </argument>
                <argument>
                  ${project.basedir}/target/art-1.0/WEB-INF/export
                </argument>
            </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>
于 2013-08-07T13:45:13.210 回答
0

这是我通过修补插件发现的。我已经能够创建一个包含一些任意文件的 zip。这是我定义的插件:

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <descriptors>
                    <descriptor>src/main/resources/my-assembly.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>assembly-id</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

继承人my-assembly.xml:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>zip-example</id>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>src/main/java/com/sandbox</directory>
        </fileSet>
    </fileSets>

</assembly>

希望有一种更简单的方法可以满足您的需求,但是从这一点开始,您可以为需要构建的每个 zip 创建一个程序集文件,这对您有用。

于 2013-07-05T20:12:18.313 回答