【问题标题】:maven to put the built bundles in modules folder instead of local repositorymaven 将构建的包放在模块文件夹而不是本地存储库中
【发布时间】:2016-11-21 01:19:09
【问题描述】:

我有一个包含很多模块的多模块 maven 项目,我想将构建的包存储在每个模块的相应文件夹中,即 buildbundle。现在,众所周知,maven 将所有内容存储在.m2/repository 下。但是,我们希望为每个项目更改它。我寻找了一个解决方案,但他们中的大多数建议更改整个存储库的位置,这不是我们想要的。

有没有办法告诉 maven 将构建的包放入相应模块的 build 文件夹?

为了说明我们想要的方式,可以检查一下:

现在

 + m2
   + repository
     + localGroup
       + moduleName   <-- compiled bundle goes here

我们想要什么:

+ workspace
  + localGroup
    + moduleName
      + src
      + **build**  <-- compiled bundle goes here
      + pom.xml
      + .
      + .
      + ...

注意:我必须说它不一定要将它们编译到文件夹中,可以通过从.m2/repository复制到相应模块的构建文件夹来完成。我听说在这方面有一个plugin,用来复制模块内的东西。

【问题讨论】:

  • 为什么要这样做?最终目标是什么?

标签: maven


【解决方案1】:

好的,这样就解决了我的问题:

<plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
          <executions>
            <execution>
              <id>copy-installed</id>
              <phase>install</phase>
              <goals>
                <goal>copy</goal>
              </goals>
              <configuration>
                <artifactItems>
                  <artifactItem>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${project.artifactId}</artifactId>
                    <version>${project.version}</version>
                    <type>${project.packaging}</type>
                  </artifactItem>
                </artifactItems>
                <outputDirectory>build</outputDirectory>
              </configuration>
            </execution>
          </executions>
</plugin>

注意,这样指定build文件夹就够了,因为maven使用的是项目本身的相对路径,所以不需要给文件夹的绝对路径什么的。

【讨论】:

    猜你喜欢
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-22
    • 2013-06-26
    • 2015-03-21
    • 2016-10-27
    • 2014-09-28
    相关资源
    最近更新 更多