开发者

With Maven2, how would I specify a custom directory to which a dependency should be copied?

开发者 https://www.devze.com 2022-12-30 06:13 出处:网络
Basically, I have a multi-module project consisting of 5 different modules. One of the modules is kind of the parent module to the other 4, meaning the other 4 need to be built before the 5th, so you

Basically, I have a multi-module project consisting of 5 different modules. One of the modules is kind of the parent module to the other 4, meaning the other 4 need to be built before the 5th, so you could say that each of the 4 modules is a dependency of the 5th. Thus, I've made dependency entries for each of the modules in the 5th module's pom.xml.

However, when I build the project, I don't want those 4 dependencies copied to the "lib" directory of the 5th module. I'd like to specify the directory into which each of them should be placed explicitly.

Is the开发者_运维百科re any way to do this with Maven2?

Thanks for your help,

B.J.


I'm not sure I understood everything (from where does this lib directory come from, when do you want the copy to happen exactly?) but the Maven Dependency Plugin might help, its dependency:copy goal takes an outputDirectory per dependency. Below the sample taken from the Usage page:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>[ groupId ]</groupId>
                  <artifactId>[ artifactId ]</artifactId>
                  <version>[ version ]</version>
                  <type>[ packaging ]</type>
                  <classifier> [classifier - optional] </classifier>
                  <overWrite>[ true or false ]</overWrite>
                  <outputDirectory>[ output directory ]</outputDirectory>
                  <destFileName>[ filename ]</destFileName>
                </artifactItem>
              </artifactItems>
              <!-- other configurations here -->
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

Change the lifecycle phase binding according to your needs.

But as I said, this answer is more an hint, maybe using a custom assembly would be more appropriate. If it doesn't help, please provide more details.

0

精彩评论

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