I have problem with relations of pom, with dependency versions etc. Below my structure:
My MAIN pom, which gives me the order to build of all projects
<groupId>com.xyz</groupId>
<artifactId>yxz</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>xyz</name>
<modules>
<module>commons</module>
<module>projectA</module>
<module>ProjectB</module>
...
<module>ProjectX</module>
</modules>
COMMONS pom, it is designed to have common dependencies and properties, without any parent
<groupId>com.xyz</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
<name>commons</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.version>3.8.1</maven.compiler.version>
<java.version>11</java.version>
<lombok.version>1.18.24</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
ProjectA pom, include commons dependency, with spring-boot in parent,
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xyz</groupId>
<artifactId>projectA</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>projectA</name>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>com.xyz</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
<dependency>
some dependencies from org.springframework.cloud
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
...
</build>
ProjectB pom, include commons dependency, with custom framework in parent,
<parent>
<groupId>com.customframework</groupId>
<artifactId>custom.framework</artifactId>
<version>1.8.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xyz</groupId>
<artifactId>projectB</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>projectB</name>
<properties>
<java.version>11</java.version>
<customeframework.feign.version>10.12</customeframework.feign.version>
</properties>
<dependencies>
<dependency>
<groupId>com.xyz</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
<version>11.8</version>
</dependency>
other feign dependecies with 11.8 version
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.customframework</groupId>
<artifactId>custom.framework.feign</artifactId>
<version>${customeframework.feign.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
...
</build>
When i build my all projects then:
projectA has lombok with version from springframework.cloud dependency management, not with version from commons
ProjectB has similar problem with feign, if i add feign dependency with version 11.8, maven use version from customframework (version 9.x)
What i want to do:
I tried add bom pom file, like next module to MAIN pom but how should i add it when i have other dependency management from springframework.cloud
i have 5-6 projects with spring boot parent, some with quarqus and with custom framework and i want configure all dependency versions and parent spring boot versions in one file
If you want to have the same dependencies in all modules then how about you define <dependencyManagement> with all required BOMs and versions in one place (e.g. in commons module)?
It won't bother the modules if they don't include some of the dependencies but it will make sure that all the modules have the same dependencyManagement rules.
Related
Trying to specify my vertx version for different modules in the parent pom.
My parent pom file is:
<groupId>com.abc.xyc</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Parent POM</name>
<modules>
...
<module>Server</module>
...
</modules>
<properties>
...
<vertx.version>3.8.2</vertx.version>
<vertx.verticle>com.abc.xyc.as4.MainVerticle</vertx.verticle>
<vertx-maven-plugin.version>1.0.22</vertx-maven-plugin.version>
<lmax.version>3.4.2</lmax.version>
...
</properties>
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
</dependency>
...
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
...
<plugins>
<plugin>
<groupId>io.reactiverse</groupId>
<artifactId>vertx-maven-plugin</artifactId>
<version>${vertx-maven-plugin.version}</version>
<executions>
<execution>
<id>vmp</id>
<goals>
<goal>initialize</goal>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<redeploy>true</redeploy>
</configuration>
</plugin>
</plugins>
</pluginManageme>
</build>
This is my child pom file
<artifactId>Server</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>com.abc.xyc</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
...
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
</dependency>
...
</dependencies>
The error I get is:'dependencies.dependency.version' for io.vertx:vertx-stack-depchain:jar is missing. When I specify the version in child pom, it works fine. My question is why isn't it getting the version from my parent pom?
It's because it does not "manage" its own version, it manages other dependencies via <dependencyManagement>.
In general, there is no need to import the vertx-stack-depchain as a depenedency, it should be a parent or like you did in dependency-management with <scope>import</scope> and then you can do things like the following in your child poms:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
If you still find a good reason to import the dep-chain itself, then you need to specify the version.
I am reading spring-boot doc and there they said that
To create an executable jar we need to add the spring-boot-maven-plugin to our pom.xml. Insert the following lines just below the dependencies section
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Following are my main pom which includes other module
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<groupId>de.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<description>demo</description>
<properties>
<java.version>1.6</java.version>
<joda.version>2.5</joda.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- joda time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>db</module>
<module>web</module>
</modules>
following is the db
<parent>
<groupId>de.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>db<artifactId>
<description>demo</description>
<dependencyManagement>
<dependencies>
<!-- spring data jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<!-- hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
following is web
<parent>
<groupId>de.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>web</artifactId>
<dependencyManagement>
<dependency>
<groupId>com.example</groupId>
<artifactId>db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencyManagement>
I have created multi-module project. I am using spring boot parent. In any of my modules pom I do not have above plugin but still it create jar file in target folder after I run following command on web module as base directory
mvn clean install spring-boot:run
I am missing any thing to understand. Please do comment.
Maven uses maven-jar-plugin to build a non executable jar file and spring-boot-maven-plugin is used to create an executable jar.
In you case even though you do not specify the spring-boot-maven-plugin, the maven-jar-plugin will create the jar file.
You can check this when you do a mvn install and see the build logs.
I'm currently working on a REST API with Spring Boot.
I'm new to Maven and have just started coding with IDEA (don't know well this IDE yet), and I have a problem...
Here is my project structure :
parent
pom.xml
main module
controller
domain
App.java (Spring Boot main class)
pom.xml
sub module (need main module as dependency)
controllers
domain
pom.xml
So when I run the project in Intellij, it starts, and I can access all URLs defined in the main module controller. But not the ones in the sub module controller... It looks like only the main module was loaded.
Here is my parent pom.xml :
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>Test :: Test :: Parent POM</name>
<groupId>test.test.test</groupId>
<artifactId>project-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<!-- Specify Java Compiler Version -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Spring -->
<spring-boot.version>1.2.1.RELEASE</spring-boot.version>
<!-- Sonar -->
<sonar-maven-plugin.version>2.5</sonar-maven-plugin.version>
<sonar.language>java</sonar.language>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<!-- Plugin -->
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<jacoco-maven-plugin.version>0.7.3.201502191951</jacoco-maven-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>submodule</module>
<module>main</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<includes>
<include>**/*Test.java</include>
<include>**/*IT.java</include>
<include>**/*Story.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<destFile>${project.basedir}/../target/jacoco.exec</destFile>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
</project>
Here my main module pom.xml :
<project>
<parent>
<artifactId>project-parent</artifactId>
<groupId>test.test.test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>main</artifactId>
<name>Test :: Test :: Main</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<commons-lang3.version>3.3.2</commons-lang3.version>
<commons-codec.version>1.10</commons-codec.version>
<jsr305.version>3.0.0</jsr305.version>
<!-- Testing dependencies -->
<http-commons.version>4.3.6</http-commons.version>
<jbehave.version>3.9.5</jbehave.version>
<assertj.version>1.7.1</assertj.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${jsr305.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http-commons.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>${http-commons.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-spring</artifactId>
<version>${jbehave.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
And here the sub module pom.xml :
<project>
<parent>
<artifactId>project-parent</artifactId>
<groupId>test.test.test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>submodule</artifactId>
<name>Test :: Test :: Submodule</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<commons-lang3.version>3.3.2</commons-lang3.version>
<commons-codec.version>1.10</commons-codec.version>
<jsr305.version>3.0.0</jsr305.version>
<!-- Testing dependencies -->
<http-commons.version>4.3.6</http-commons.version>
<jbehave.version>3.9.5</jbehave.version>
<assertj.version>1.7.1</assertj.version>
</properties>
<dependencies>
<dependency>
<groupId>test.test.test</groupId>
<artifactId>main</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
I think that's correct, but not sure...
I run the project in Intellij with Maven with config :
working directory is root (not sub-module)
command line mvn spring-boot:run -Drun.arguments=--spring.profiles.active=dev -e -pl main
property start-class with parent.main.App
Need your help to configure all that stuff to run Spring Boot with all sub-modules loaded in the IDE for dev purpose... because I readlly don't know what is wrong in my config !
Thx !
You need to tell SpringBoot where to look for your controllers. Per default that only happens in sub-packages of your #SpringBootApplication class (which will probably not include your sub module).
In order to change that you can use #ComponentScan("path.to.package") to change the default package.
Additionally, you can use #EntityScan to do the same for #Entity classes that might be in your sub-module.
Your project structured as:
parent
pom.xml
main module
controller
domain
App.java (Spring Boot main class)
pom.xml (add sub moudle to main module as dependency)
sub module
controllers
domain
pom.xm
if your App.java in a package: com.xxxx.pro,then set the sub module's package is com.xxx.pro,such as your sub module's controller is TestController.java, and the code is:
package com.xx.pro.web;
#RestController
public class TestController{
}
so, this sub moudle's TestController will be sanned by App.java.Try it on, good luck.
also note that in case of JPA Entities and repositories are not in sub packages of Application.java's package then #Entityscan and #EnableJpaRepositories MUST be declared in the Application class, e.g:
#Configuration
#ComponentScan(basePackages="com.my.pack")
#EnableAutoConfiguration
#EnableJpaRepositories(basePackages="com.my.pack")
#EntityScan(basePackages="com.my.pack")
public class Application{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
I want to try something new and use Dagger 2 as my DI framework. So I have the following pom and the "hello world" coffee maker classes (http://google.github.io/dagger/) in my projekt.
But when I do a mvn clean install no classes get generated. As far as I unterstood there should be a "Dagger_CoffeeShop" class generated. Hmmm ... what am I missing?
<modelVersion>4.0.0</modelVersion>
<groupId>kic</groupId>
<artifactId>xfoo</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
For those using Gradle: Make sure you are referencing the Dagger dependencies as following:
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
And in the case if you are running into apt not supported, add
1) Into module app\build.gradle:
apply plugin: 'com.neenbedankt.android-apt'
2) Into project \build.gradle:
buildscript {
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
I had the same problem, only with the release version 2.0.
In my case the following two steps solved this problem:
Adding target/generated-sources/annotations to my build path
Adding <forceJavacCompilerUse>true</forceJavacCompilerUse> to the maven compiler plugin
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- workaround for https://issues.apache.org/jira/browse/MCOMPILER-202 -->
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
</plugin>
See also:
https://github.com/google/dagger/pull/103
https://issues.apache.org/jira/browse/MCOMPILER-202
This isn't the best answer. When I used the downloaded JAR files (commented out in the POM file below) mine also wasn't generating the Dagger_ files. Once I added the repository to the POM, everything was working fine.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hello</groupId>
<artifactId>hellodagger</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hellodagger</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>sonatype</id>
<name>sonatype-repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.0-SNAPSHOT</version>
<!--<scope>system</scope>-->
<!--<systemPath>${project.basedir}/dagger-2.0-20141216.223138-12.jar</systemPath>-->
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0-SNAPSHOT</version>
<optional>true</optional>
<!--<scope>system</scope>-->
<!--<systemPath>${project.basedir}/dagger-compiler-2.0-20141216.223201-12-jar-with-dependencies.jar</systemPath>-->
</dependency>
</dependencies>
</project>
I have searched over SO and Internet, but no success. This is what I have in short:
Multimodule project with dev and appserv profile. When dev profile is used (just mvn clean install because default=true), then load specific dependencies. One dependency is Child-A that must be loaded in Child-B. I am building always from parent POM.
I have profile defined in parent POM with activation and in Child-B I have same profile with dependencies.
This is my parent POM:
<project ..>
<groupId>com.organisation</groupId>
<artifactId>project-name</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>child-b</module>
<module>child-a</module>
</modules>
<properties>
<javax.ws.rs.version>2.0</javax.ws.rs.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- project dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>child-a</artifactId>
<version>${project.version}</version>
</dependency>
<!-- build dependencies -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>child-a</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>app-server</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>env</name>
<value>app-server</value>
</property>
</activation>
</profile>
</profiles>
</project>
My Child-B module that calls Child-A, the IDE as well when building Child-B doesn't see Child-A's classes.
<project ..>
<parent>
<groupId>com.organisation</groupId>
<artifactId>project-name</artifactId>
<version>1.0</version>
</parent>
<artifactId>child-b</artifactId>
<packaging>jar</packaging>
<profiles>
<profile>
<id>dev</id>
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>child-a</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>app-server</id>
<dependencies>
...
</dependencies>
</profile>
</profiles>
<dependencies>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
...
</dependencies>
</project>
I don't see what is wrong here and can't understand where the problem is, why Child-B doesn't take Child-A as dependency. In parent POM inside profile I have tried to remove the dependencyManagement, but the result was still same - Child-A not seen in Child-B module. Apparently without the profiles everything was working fine.
In Child-b you put a dependency to child-b instead of a dependency to child-a
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>child-b</artifactId>
</dependency>
instead of
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>child-a</artifactId>
</dependency>