Maven site in project with multiple modules could not resolve dependency

I want to divide my continuous integration work (Hudson) into two phases. (Because the lead time with assembly and reporting takes too much time.) In the first task, I successfully create a multi module maven project with the "mvn package". Then I copy my workspace to another place and again try to build the project only with the goal of "site" and / or findbugs / checkstyle / pmd to create reports. But that will not work! Maven cannot resolve the dependency of my submodules. (But all JARs are available in destination folders.)

Example: My structure looks like this:

  • Parent
    • A
    • IN
    • FROM
    • D

Project C has dependency project B.

When I create everything using the "mvn site", it generates for all projects A and B. But I stopped in project C with the error message "Could not resolve dependencies for project B." But project B is already built with the "mvn" package. That is, I can find the project B JAR file in my target folder.

Is there any way to resolve dependency on submodule B without installing "mvn install"? (I do not want to do this on my ci server. I am afraid that this could be dangerous for other jobs with the same code base.)

Update 08/20/12:

POM root folder:

<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> <name>Foo</name> <groupId>foo</groupId> <artifactId>bar</artifactId> <version>1.0</version> <packaging>pom</packaging> <modules> <module>parent</module> </modules> </project> 

Parent 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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <name>Foo</name> <groupId>foo</groupId> <artifactId>parent</artifactId> <version>1.0</version> <packaging>pom</packaging> <modules> <module>../bar-a</module> <module>../bar-b</module> <module>../bar-c</module> <module>../bar-d</module> </modules> [...] <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>2.5.1</version> [...] </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>2.7.1</version> [...] </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> [...] </plugin> </plugins> </reporting> </project> 

POM of B:

 <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> <parent> <groupId>foo</groupId> <artifactId>parent</artifactId> <version>1.0</version> <relativePath>../parent</relativePath> </parent> <name>Bar B</name> <artifactId>bar-b</artifactId> <version>1.0</version> <packaging>jar</packaging> [...] </project> 

POM of C:

 <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> <parent> <groupId>foo</groupId> <artifactId>parent</artifactId> <version>1.0</version> <relativePath>../parent</relativePath> </parent> <name>Bar C</name> <artifactId>bar-c</artifactId> <packaging>jar</packaging> [...] <dependencies> <dependency> <groupId>foo</groupId> <artifactId>bar-b</artifactId> <version>1.0</version> </dependency> </dependencies> [...] </project> 
+6
source share
1 answer

I came across the same "long time" question.

The only way (I think) to solve it using your way of working is really mvn install, as you suggested.

But the problem is that you are trying to change the behavior when copying your workspace. You should instead think that CI will build and test as often as you want (every latch or every hour), but only make messages once (for example, every midnight). You could have faster continuous builds, as well as correct documentation and reporting at night.

This is how we work, and that’s enough. We use Jenkins for this, but you can run it with every soft core, I think)!

 @hourly : mvn clean package (or install) --> from 1 to 5 minutes to run all test on all modules @daily : mvn clean install site --> from 15 to 35 minutes to run all test on all modules + doc + reports + PDF reports 

You can also use profiles to trigger various actions, but it is too complicated for such basic use.

+1
source

Source: https://habr.com/ru/post/923124/


All Articles