2

Initial question : "I'm a beginner in java programming and i'm a bit lost. I've issues with my current project. Indeed, I try to generate reports with the command mvn site but it seems that some reports are missing. I try to generate jacoco, surefire and findbugs report. How can I modify my build to generate these reports ? I link my pom.xml and the result. Thank you in advance for your help."

Thank you a lot for your answer. Ive modified my Pom following your advices. I still have issues. Here is my POM.xml. Thank you again for your help. Kind regards.

<?xml version="1.0" encoding="UTF-8"?>

4.0.0 com.parkit parking-system 1.0-SNAPSHOT jar

<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>

<url>D:/Workspace/parkingsystem/target/site/</url>


<dependencies>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.17.0</version>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.22.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.17.0</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.25</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.8.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.8.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-junit-jupiter</artifactId>
        <version>4.2.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.7</version>
        <type>maven-plugin</type>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.maven/maven-plugin-api -->
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>3.8.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-math3</artifactId>
        <version>3.6.1</version>
    </dependency>
</dependencies>

<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>
                                    com.parkit.parkingsystem.App
                                </mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.10.0</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <phase>integration-test</phase>
                    <configuration>
                        <excludes>
                            <exclude>none</exclude>
                        </excludes>
                        <includes>
                            <include>**/*IT.java</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.7</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jacoco-report</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
    [INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< com.parkit:parking-system >----------------------
[INFO] Building parking-system 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-site-plugin:3.10.0:site (default-site) @ parking-system ---
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.2
[INFO] 15 reports detected for maven-project-info-reports-plugin:3.1.2: ci-management, dependencies, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing
-lists, modules, plugin-management, plugins, scm, summary, team
[INFO] Rendering site with default locale English (en)
[INFO] Relativizing decoration links with respect to localized project URL: D:/Workspace/parkingsystem/target/site/
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.3 skin.
[INFO] Generating "Dependencies" report  --- maven-project-info-reports-plugin:3.1.2:dependencies
[INFO] Unable to create Maven project from repository for artifact 'org.apache.maven:maven-artifact-manager:jar:2.0.2', for more information run with -X
[INFO] Unable to create Maven project from repository for artifact 'org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-6', for more information run with -X
[INFO] Unable to create Maven project from repository for artifact 'org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9', for more information run with -X
[INFO] Unable to create Maven project from repository for artifact 'org.apache.maven:maven-artifact-manager:jar:2.0.2', for more information run with -X
[INFO] Unable to create Maven project from repository for artifact 'org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-6', for more information run with -X
[INFO] Unable to create Maven project from repository for artifact 'org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9', for more information run with -X
[INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:3.1.2:dependency-info
[INFO] Generating "About" report         --- maven-project-info-reports-plugin:3.1.2:index
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:3.1.2:plugin-management
[INFO] Generating "Plugins" report       --- maven-project-info-reports-plugin:3.1.2:plugins
[INFO] Generating "Summary" report       --- maven-project-info-reports-plugin:3.1.2:summary
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.094 s
[INFO] Finished at: 2022-01-18T11:57:00+01:00
[INFO] ------------------------------------------------------------------------

EXAMPLES OF ERRORS WHEN I RUN IN DEBUG MODE :

2 problems were encountered while building the effective model for org.codehaus.plexus:plexus-container-default:1.0-alpha-9 [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 13, column 15 [ERROR] 'distributionManagement.status' must not be specified. @ line 43, column 13

org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [ERROR] 'distributionManagement.status' must not be specified. @ line 43, column 13

Azu
  • 21
  • 2
  • You are excluding a lot of stuff from dependencies, have you tried just keeping it in? Usually in these cases the easiest thing to do is make a simplified version of the pom and tweak that until it fails, then you know what has failed. Also sometimes it's worth trying older versions. – Igor Flakiewicz Jan 17 '22 at 16:45
  • You are excluding log4j-api in one dependency but adding it yourself ... That does not make sense...apart from that I would suggest to use a more recent version... furthermore excluding dependencies from plugins ? Why are you doing that? Also excluding junit-jupiter-api from mockito-junit-jupiter which does not make sense because you are using it... Also excluding things from `jacoco-maven-plugin` which does not make sense either because those dependencies (if they are really those) are needed by the plugin.. Why do you have `maven-plugin-api` as a dependency? Wrong! – khmarbaise Jan 17 '22 at 17:22
  • 1
    Also other dependencies like `maven-assembly-plugin` doesn't make sense either ...furthermore using `maven-surefire-plugin` but excluding `*IT.java`which is the default ? Also adding a dependency `junit-platform-surefire-provider` which is wrong... There are so many things wrong...in particular if you are a beginner in Java you shouldn't simply add stuff to your pom file without know what you are doing there... – khmarbaise Jan 17 '22 at 17:25
  • @khmarbaise Hi, Thank ou for your answer. Ive update my question. Thank's again for the help. – Azu Jan 18 '22 at 20:59
  • You may have a look at my answer on [maven jacoco: not generating code coverage report](https://stackoverflow.com/questions/25395255/maven-jacoco-not-generating-code-coverage-report/71661614#71661614). – Murat Yıldız Mar 29 '22 at 12:01

0 Answers0