Example scenario: I have 2 projects, "common-project" and "application-project". The project application depends on the API provided by the overall project. There are also third-party banks (guava example) used by both projects.
I would create 3 maven projects: the parent aggregate module, the common-project module and the application-project module depending on the common-project and declare guava as a dependency in the parent module (so that the child project will inherit it). Something like that:
$ tree Q3337426
Q3337426
βββ application-project
β βββ pom.xml
β βββ src
β βββ main
β βββ ...
β βββ test
β βββ ...
βββ common-project
β βββ pom.xml
β βββ src
β βββ main
β βββ ...
β βββ test
β βββ ...
βββ pom.xml
Where the parent pom.xml is as follows:
<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.stackoverflow.Q3337426</groupId> <artifactId>Q3337426</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <name>Q3337426 - Root</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>r05</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <modules> <module>common-project</module> <module>application-project</module> </modules> </project>
pom.xml for a common project:
<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> <parent> <artifactId>Q3337426</artifactId> <groupId>com.stackoverflow.Q3337426</groupId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>common-project</artifactId> <name>Q3337426 - Common Project</name> <dependencies/> </project>
pom.xml for the project application:
<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> <parent> <artifactId>Q3337426</artifactId> <groupId>com.stackoverflow.Q3337426</groupId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>application-project</artifactId> <name>Q3337426 - Application Project</name> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>common-project</artifactId> <version>${project.version}</version> </dependency> </dependencies> </project>
This is Mavenβs way of organizing such a project and will allow you to start the reactor assembly from the root project to create everything.
(...) Both projects are under active development, so I would prefer not to first create a jar of a common project, and then βinstallβ it into my local repository before I can use the new features in the -project application.
The m2eclipse plugin can resolve dependencies on Workspace projects (this is actually the default behavior). Therefore, if you import both application-project and common-project , the first one will be configured to depend on the sources of common-project (instead of hanging with a jar). Changes made to the common-project will be immediately visible when using this setting.
This should solve your problem inside the IDE. Outside the IDE, run the reactor on the top project.