I am trying to use a "common" module as a dependency in a separate module, both modules being submodules of one parent module. mvn clean install
completes successfully, but trying to compile the module with the dependency fails as it doesn't know where to look for the POM or JAR files. This is in a javax project.
Parent pom
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>project</groupId>
<artifactId>quotations</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>quotations</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<modules>
<module>common</module>
<module>service1</module>
</modules>
</project>
common pom
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>service-ad</groupId>
<artifactId>common</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
service1 pom
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>service-ad</groupId>
<artifactId>service1</artifactId>
<version>1.0</version>
<properties>
<main.class>service.core.Quoter</main.class>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>service-ad</groupId>
<artifactId>common</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>jsr181-api</artifactId>
<version>1.0-MR1</version>
</dependency>
<dependency>
<groupId>javax.jmdns</groupId>
<artifactId>jmdns</artifactId>
<version>3.4.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>${main.class}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
execution output:
──── ─ mvn compile exec:java -pl service1 -U
Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/conor/.config/java
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< service-ad:service1>-------------------------
[INFO] Building service1 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/service-ad/common/1.0/common-1.0.pom
[WARNING] The POM for service-ad:common:jar:1.0 is missing, no dependency information available
Downloading from central: https://repo.maven.apache.org/maven2/service-ad/common/1.0/common-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.347 s
[INFO] Finished at: 2021-10-03T15:22:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project service1: Could not resolve dependencies for project service-ad:service1:jar:1.0: Could not find artifact service-ad:common:jar:1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Directory structure:
project -
|- pom.xml
|- common -
|- pom.xml
|- src folder
|- target folder
|-service1-
|- pom.xml
|- src folder
|- target folder