0

I'm looking for the simple way to generate the child project artifact in the parent project directory using maven.

I have tried directory-maven-plugin and assigned a variable to the parent project. And I've provided this variable in the child pom. Now the child is trying to create a folder with Parent name in it instead of copying the dependencies to parent project folder

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>

Child jar file is getting generated inside child folder instead of parent folder like below- child/c:/foldername/workspace/parent/target/child.jar

What I'm looking for should be like this- parent/target/child.jar

Madhu Stv
  • 89
  • 2
  • 8
  • what "you are looking for" is "strange maven usage", but possible: https://stackoverflow.com/q/4757426/592355 (who cares for `target` folder? it's getting deleted like every 2 minutes... (in maven) you obtain your dependencies/artifacts ideally from repository) – xerx593 Jan 24 '19 at 19:08
  • The command line option and parameter expressions fail to create the child artifacts on the parent folder. – Madhu Stv Jan 28 '19 at 10:28

1 Answers1

0

create several modules in parent pom as below

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

refer the link http://websystique.com/maven/creating-maven-multi-module-project-with-eclipse/

TheSprinter
  • 1,523
  • 17
  • 30