【问题标题】:How to generate child project build in parent project directory如何在父项目目录中生成子项目构建
【发布时间】:2019-01-24 16:51:20
【问题描述】:

我正在寻找使用maven在父项目目录中生成子项目工件的简单方法。

我尝试了 directory-maven-plugin 并为父项目分配了一个变量。我已经在子 pom.xml 中提供了这个变量。现在孩子正在尝试创建一个包含 Parent 名称的文件夹,而不是将依赖项复制到父项目文件夹

父.pom

<modelVersion>4.0.0</modelVersion>
<groupId>com.parent.project</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>  
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
<version>0.1</version>
<executions>
  <execution>
    <id>directories</id>
    <goals>
     <goal>highest-basedir</goal>
    </goals>
   <phase>initialize</phase>
   <configuration>
     <property>main.basedir</property>
   </configuration>
 </execution>
</executions>
</plugin>
</plugins>
</build>

<modules>
    <module>child</module>  
</modules>

child.pom

<groupId>com.wellsfargo.1coh</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<parent>
<groupId>com.parent.project</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>  
</parent>
<build>
 <directory>${main.basedir}/target/</directory>
</build>

子 jar 文件在子文件夹而不是父文件夹中生成,如下所示 - child/c:/foldername/workspace/parent/target/child.jar

我要找的应该是这样的—— 父/目标/child.jar

【问题讨论】:

  • “你正在寻找的”是“奇怪的 maven 用法”,但可能:stackoverflow.com/q/4757426/592355(谁在乎target 文件夹?它每 2 分钟就会被删除一次......(在 maven 中) ) 您最好从存储库中获取您的依赖项/工件)
  • 命令行选项和参数表达式无法在父文件夹上创建子工件。

标签: maven maven-3


【解决方案1】:

在父 pom 中创建几个模块,如下所示

  <modules>
    <module>ChildProjectB</module>
    <module>ChildProjectC</module>
    <module>ChildProjectD</module>
  </modules>

参考链接 http://websystique.com/maven/creating-maven-multi-module-project-with-eclipse/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    相关资源
    最近更新 更多