When I try to connect a module to another module ( Project Structure -> Modules -> Dependencies -> Add Module Dependency ), IDEA says that the root project cannot have a source root directory, as it belongs to another module ( and the way it is, but what’s the reason for the root project). Here is a screenshot of the error and folder hierarchy:

enter image description here


pom.xml root project:

 <?xml version="1.0" encoding="UTF-8"?> <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.dugin.rostislav</groupId> <artifactId>OSLoaderServer</artifactId> <name>OSLoaderServer</name> <packaging>pom</packaging> <version>1.0</version> <modules> <module>RostislavUtil</module> <module>StorageModule</module> <module>HandlingModule</module> </modules> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.8</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>jsr305</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20160212</version> </dependency> <dependency> <groupId>com.google.inject</groupId> <artifactId>guice</artifactId> <version>4.0</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> </dependencies> </project> 

pom.xml of the RostislavUtil module:

 <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> <artifactId>RostislavUtil</artifactId> <version>1.0</version> <name>RostislavUtil</name> <parent> <groupId>com.dugin.rostislav</groupId> <artifactId>OSLoaderServer</artifactId> <version>1.0</version> <relativePath>../pom.xml</relativePath> </parent> </project> 

What is the error and how to fix it?

  • if you pack your project as pom , then there should be neither raw materials nor resources in it. Only submodules and pom.xml file - Temka also

1 answer 1

Found the answer by chance. In the next section Paths root module simply deleted all the directories with source codes and tests, the module paths were added there (for some reason). After that, everything worked.