I have a large Maven project with one master module and lots of children, organized in a nice tree structure. However, some of the modules need special settings which would caus
Don't use profile, Mateusz Balbus answer, that is define nested pom-packaged project that define java and scala modules respectively
If you want to configure maven profile for each project(module) then you have to add profile setting in the project(module) pom.xml file
<profiles>
<profile>
<activation>
<jdk>1.4</jdk>
</activation>
<your properties goes here>
</profile>
</profiles>
Also if you do not want to execute some profile then you have to add
mvn groupId:artifactId:goal -P !profile-1,!profile-2
in the project pom.xml file
As far as I understood you want to activate profile from child pom based on its configuration. I'm afraid it is not possible. However you can reorganize project tree structure to take advantage of pom inheritance:
pom.xml // general properties for all projects
|-- java-modules
| -- pom.xml // inherits from master pom, configures maven-compile-plugin
| -- java-8-modules
| -- pom.xml // inherits from java-modules pom, uses java 8 compiler
| -- java-8-project-a
| -- java-7-modules
| -- pom.xml // inherits from java-modules pom, uses java 7 compiler
| -- java-7-project-a
|-- scala-modules
-- pom.xml // inherits from master pom, configures maven-scala-plugin
-- scala-project-a
You write one master pom for all modules in top directory, child poms just specify java/scala details.
More about pom inheritance https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Inheritance