0

I have a multi-module maven project with a lot of modules, and I'd like to store the built bundles in the respective folder of each module, i.e build or bundle. Right now, as we all know, maven stores everything under .m2/repository. However, we want to change it for every project. I looked for a solution but most of them suggest the location change of the whole repository, which is not what we want.

Is there a way to tell maven to put the built bundle to the respective module's build folder?

To illustrate how we want, this can be checked:

Now:

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

What we want:

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

Note: I must say that it does not necessarily have to compile them into the folders, it can be done via copying from .m2/repository to the build folder of the respective modules. I heard that there is a plugin used in this regard, to copy stuff inside the modules.

Community
  • 1
  • 1
Schütze
  • 1,044
  • 5
  • 28
  • 48

1 Answers1

0

OK, so this kinda solved my problem:

<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>

Note that it is enough to specify the build folder like this, because maven uses the relative path of the project itself, so no need to give an absolute path of the folder or something.

Schütze
  • 1,044
  • 5
  • 28
  • 48