开发者

how to assemble external artifacts into one global directory with the maven-assembly-plugin (or otherwise)

I am experimenting with Maven and I am trying to mavenize a project originally build with shell scripts.

With the Maven rule-of-thumb: one project, one artifact, I created the following structure:

<PROJECT&g开发者_如何学编程t;
  <MODULE-1>
  <MODULE-2>
  <MODULE-3>
  ..
  <MODULE-N>
  <RESOURCES>     
  <DISTRIB>

The RESOURCES module is structured as follows:

<RESOURCES>/src/main/resources/<MODULE-1>/bin
<RESOURCES>/src/main/resources/<MODULE-1>/lib
<RESOURCES>/src/main/resources/<MODULE-1>/doc
<RESOURCES>/src/main/resources/<MODULE-2>/bin
<RESOURCES>/src/main/resources/<MODULE-2>/lib
<RESOURCES>/src/main/resources/<MODULE-2>/doc
...
<RESOURCES>/src/main/resources/<MODULE-N>/bin
<RESOURCES>/src/main/resources/<MODULE-N>/lib
<RESOURCES>/src/main/resources/<MODULE-N>/doc

The reason for doing it this way was that the resources above are needed at runtime, not compile-time and they are mostly property files, config files and shell scripts to invoke the various jar-files. For the final resources step, I wanted to combine the subdirectories into one global bin/lib/doc directory. However, I do not see an option in the assembly descriptor to strip of the prefix of the modules to get to what I want:

 <RESOURCES>/target/resources/bin
 <RESOURCES>/target/resources/lib
 <RESOURCES>/target/resources/doc

where bin would contain all the files found in the /src/main/resources//bin directory, /src/main/resources//bin directory etc. Similarly for lib, doc.

My question: should I have a:

<MODULE-1>/src/external/resources/bin
<MODULE-1>/src/external/resources/lib
<MODULE-1>/src/external/resources/doc
...
<MODULE-N>/src/external/resources/bin
<MODULE-N>/src/external/resources/lib
<MODULE-N>/src/external/resources/doc

structure instead, that I would then access through a dependency-set? These files should not be part of the jar-file of the various modules and therefore cannot be stored in src/main/resources of their respective projects. Or is what I want to achieve doable by using some other maven plugin instead?

In the DISTRIB module I would combine the output of the RESOURCES module with the JAR-files and dependencies to create a directory structure that would then be used with a packaging tool (Solaris package and WiX installer).

Any help would be appreciated!


In the pom fort he resources module set the source directory to something other than /src/main/resources/ so that it does not copy them to the target folder. Then use the Maven Resources Plugin to copy the resource files to target/bin and target lib etc.

e.g.

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>target/bin/</outputDirectory>
                <resources>
                    <resource>
            <directory>src/external/resources/bin</directory>
                <filtering>false</filtering>
        </resource>
        </resources>
    </configuration>
    </execution>
        <execution>
            <id>copy-resources</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>target/lib/</outputDirectory>
                <resources>
                    <resource>
            <directory>src/external/resources/lib</directory>
                <filtering>false</filtering>
        </resource>
        </resources>
    </configuration>
    </execution>
    </executions>
</plugin>`
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜