I have a simple Maven project, looking like this
project view
There is a main pom.xml looking like this:
<?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>
<artifactId>piche</artifactId>
<name>PICHE project</name>
<description>PICHE project</description>
<groupId>com.pesho.piche</groupId>
<version>1.0</version>
<packaging>pom</packaging>
<properties>
<cucumber.jvm.version>1.2.5</cucumber.jvm.version>
<project.version>1.0</project.version>
<runner.folder>".."</runner.folder>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.pesho.piche</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.pesho.piche</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.jvm.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.jvm.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-guice</artifactId>
<version>${cucumber.jvm.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>${cucumber.jvm.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>core</module>
<module>test</module>
</modules>
</project>
There are two modules- core and test.
core module pom.xml:
<?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>
<artifactId>core</artifactId>
<name>Core module</name>
<description>Core Module</description>
<parent>
<groupId>com.pesho.piche</groupId>
<artifactId>piche</artifactId>
<version>1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
test module pom.xml
<?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>
<artifactId>test</artifactId>
<name>Test module</name>
<url>http://maven.apache.org</url>
<parent>
<artifactId>piche</artifactId>
<groupId>com.pesho.piche</groupId>
<version>1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.pesho.piche</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-guice</artifactId>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
</project>
I want to use code from core inside test. The dependency looks right. The project is build with no errors:
[INFO] Reactor Summary:
[INFO]
[INFO] PICHE project ..................................... SUCCESS [0.317s]
[INFO] Core module ....................................... SUCCESS [1.317s]
[INFO] Test module ....................................... SUCCESS [0.669s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.461s
[INFO] Finished at: Fri Jun 23 11:03:18 EEST 2017
[INFO] Final Memory: 17M/41M
[INFO] ------------------------------------------------------------------------
But when I try to import a class from core in my tests, the class cannot be found.
You Must make the version of core dependency in your test module pom like this
<dependencies>
<dependency>
<groupId>com.pesho.piche</groupId>
<artifactId>core</artifactId>
<version>${parent.version}</version> <!-- TODO -->
</dependency>
AND delete thoes lines in your parent POM
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.pesho.piche</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.pesho.piche</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>
AND from your parent module :
mvn clean install
I hope that will help you
Actually, the dependencies of core and test in parent pom.xml is unnecesary. To access the api in core, you just need to define the dependency in you pom and install it to local repository.
Run mvn clean install under the root directory of core, this will compile this project and package and install the jar to maven local repository. Then the dependency can meet in another project and you can access the api defined.
But any changes in core may lead you to reinstall it to local repository.
Thank you for all your answers. I noted the suggestions. The problem was that I was using default packages in the modules. Never do that! Dependencies were OK but I couldn't see them because of the classpath options.
Related
I am trying to run an unit testing and I have already installed the dependencies. Below is the pom.xml file.
<?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>org.example</groupId>
<artifactId>Lecture_1-2</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
But when I am running my test case, it still gives me the error,
Cannot resolve symbol 'test'
I have tried reloading the maven project but it has not worked.
This is what I get when importing junit. Why is this?
What is the reason for the issue?
So here is the scenario,
I am trying to compile a maven project which have some persistent classes. I have persistence.xml under src\main\resources\. This compiles fine, but I get run-time error for persistence not found which can be easily resolved if I manually move persistence.xml under META-INF dir of jar(xml file is packaged under root of the jar).
Now if I move persistence.xml under src\main\resources\META-INF I get weird compile-time error of
Fatal error compiling: java.lang.RuntimeException:
javax.annotation.processing.FilerException: Attempt to recreate a file
for type my.package.EntityClassName_
This EntityClassName can be any one of my Entity class.
I just want to package persistence.xml under META-INF directory of jar.
Can someone point out what am I missing?
I am using maven compiler source and target as 1.6 if it matters.
EDIT: This project have a parent maven 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>
<groupId>com.some.domain</groupId>
<artifactId>p-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>m1</module>
<module>m2</module>
<module>m3</module>
</modules>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<scm>
<connection>scm:git:https://some.place/project.git</connection>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.1.0.6.0</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
pom of this 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>
<groupId>com.some.domain</groupId>
<artifactId>p-parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>m2</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
</dependency>
</dependencies>
</project>
It was solved bu using -proc:none as compiler argument.
I have a problem with building a project Farma-rest which depends on my other project Farma. I put dependency in my pom.xml but it couldn't resolve dependencies for the project. It shows me this error message:
Failed to execute goal on project Farma-rest: Could not resolve dependencies for project sk.upjs.ics:Farma-rest:jar:1.0-SNAPSHOT: Could not find artifact sk.upjs.ics:Farma:jar:1.0-SNAPSHOT -> [Help 1]
Here is the pom of the first 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>sk.upjs.ics</groupId>
<artifactId>Farma</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.8-dmr</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
<version>2.44.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<scope>test</scope>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<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>
</project>
And here is the POM of the project which I want to build:
<?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>sk.upjs.ics</groupId>
<artifactId>Farma-rest</artifactId>
<version>1.0-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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.8-dmr</version>
</dependency>
<dependency>
<groupId>sk.upjs.ics</groupId>
<artifactId>Farma</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- <scope>compile</scope>-->
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.3</version>
</dependency>
</dependencies>
</project>
I tried to clean and build the project but it didn't helped.
The jar for the Farma project is not available in your local maven repo.
Check if the ~/.m2/repository/sk.upjs.ics/Farma/1.0-SNAPSHOT directory exists. It should not at this point.
Run the build for the Farma project. Maven should create the artifact and put it in your local maven repository.
Check the same directory as before. It should now exist and it should have a jar and pom in it.
Now try building Farma-rest again and it should work.
POM:
<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">
<parent>
<artifactId>deephitomi</artifactId>
<groupId>studio.deepsea</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>studio.deepsea</groupId>
<artifactId>deephitomi-client</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>studio.deepsea</groupId>
<artifactId>deephitomi-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.4.RELEASE</version>
</dependency>
</dependencies>
deephitomi-common POM:
<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">
<parent>
<artifactId>deephitomi</artifactId>
<groupId>studio.deepsea</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>studio.deepsea</groupId>
<artifactId>deephitomi-common</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.3.10.RELEASE</spring.version>
<jackson.version>2.5.3</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- 使用SpringMVC需配置 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 关系型数据库整合时需配置 如hibernate jpa等 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.4</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- mysql连接 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.18</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- aop -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.4</version>
</dependency>
<!-- servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<!-- 上传文件 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.13.Final</version>
</dependency>
</dependencies>
ERROR:
[ERROR] Failed to execute goal on project deephitomi-client: Could not resolve dependencies for project studio.deepsea:deephitomi-client:jar:1.0-SNAPSHOT: Failed to collect dependencies at studio.deepsea:deephitomi-common:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for studio.deepsea:deephitomi-common:jar:1.0-SNAPSHOT: Could not find artifact studio.deepsea:deephitomi:pom:1.0-SNAPSHOT -> [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
For me a time in the afternoon orz...
add deephitomi Pom:
<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>studio.deepsea</groupId>
<artifactId>deephitomi</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<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>
<modules>
<module>deephitomi-client</module>
<module>deephitomi-server</module>
<module>deephitomi-common</module>
<module>deephitomi-core</module>
<module>deephitomi-web</module>
</modules>
You have a project structured like this:
deephitomi
deephitomi-common
deephitomi-client
...
It seems you were running mvn test inside deephitomi-client.
When you do that,
Maven tries to find its dependency deephitomi-common in a repository.
It doesn't know that deephitomi-common is in a sibling directory,
it only looks at Maven repositories.
To be able to run mvn test inside deephitomi-client,
you can install deephitomi-common in your local Maven repository.
Run this inside deephitomi, the project root directory:
mvn install
After this, you will be able to run mvn test inside deephitomi-client:
cd deephitomi-client
mvn test
Note that if you make any changes to deephitomi-common that you want to use by deephitomi-client, then you need to repeat the mvn install step.
<project (...)>
<modelVersion>4.0.0</modelVersion>
<groupId>our.group.id</groupId>
<artifactId>parent.of.all</artifactId>
<version>3.2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<url>http://maven.apache.org</url>
<modules>
<module>module-common</module>
<module>module-A</module>
<module>module-B</module>
<module>module-C</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
(... - some external dependecies...)
</dependency>
<dependency>
(... - some external dependecies...)
</dependency>
<dependency>
(... - some external dependecies...)
</dependency>
<dependency>
<groupId>our.group.id</groupId>
<artifactId>module-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>our.group.id</groupId>
<artifactId>module-A</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>our.group.id</groupId>
<artifactId>module-B</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>our.group.id</groupId>
<artifactId>module-C</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
This is the main pom of project, that holds within some modules module-common module-A module-B module-C.
The issue that I am facing is the fact, that most of them is bing compiled and tested multiple times, because of internal dependencies between modules:
<project (...)>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>our.group.id</groupId>
<artifactId>parent.of.all</artifactId>
<version>3.2.2-SNAPSHOT</version>
</parent>
<artifactId>module-B</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
(... - some external dependecies...)
</dependency>
<dependency> <!-- internal dependency to other module -->
<groupId>our.group.id</groupId>
<artifactId>module-common</artifactId>
</dependency>
</dependencies>
</project>
The more dependencies there are, the longer it takes to build project. How can I prevent maven from doing full install on the same modules being done multiple times?