Domanda

My project consists of maven modules and a parent module. Each module will have its own xml resources. I want to change output directory of each module to parent module's directory. All the resources and class files will go to parent module's output directory. I changed outputdirectory of each submodule to parent module's output directory as the following:

<build>
       <outputDirectory>../target/classes</outputDirectory>
</build>

The problems:

  1. When i clean the parent module using eclipse clean, it doesnt copy the outputs of sub modules to parent's module's output directory because i cant change output folder of submodules to parent module's output folder through eclipse project properties.
  2. When i mvn clean install, it copies the last build sub module's output to target directory because mvn clean is executed for each sub module, and it cleans the previously build module's outputs.
  3. I want to create a single jar for all modules, is that possible?
  4. How can i combine all outputs of parent and sub modules?
È stato utile?

Soluzione

Please don't do this, this goes completely against every rule. It wouldn't work either, because modules are handled one after the other.

The reason for using different modules is to clearly separate them. Mixing output folders would sabotage that goal.

  • keep your modules separate
  • create a separate module which collects all your other modules using maven-assembly-plugin or maven-shade-plugin into a single target jar.

And, once again:

Maven projects should never, ever write outside their project's folder!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top