Maven JavaDoc listed classes twice - java

I am using the javadoc maven plugin and it creates the correct javadoc package, but all classes are created twice.
Maven dependency:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
</dependency>
My build code
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Can anyone help me please, what am I missing here?
command usage for doc generation
mvn clean install -Dresources="FirstProject/example_API"

I noticed the same problem and came upon a solution after enabling debug on the maven-javadoc-plugin maven plugin and seeing what it's doing. Specifically setting the sourcepath as shown below fixed the double listing problem for me and I've tried this on multiple version of Corretto 8 as well as Temurin 8. All had the double listing problem because it's an issue with the javadoc tool itself but setting the sourcepath manually fixed it for me.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<debug>true</debug>
<sourcepath>${basedir}/src/main/java</sourcepath>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

There's a bug in recent versions of the Maven Javadoc Plugin. The bug is known as MJAVADOC-700. It is dead easy to reproduce.
Downgrading to version 3.2.0 of the plugin fixes the problem. Setting the sourcepath explicitly is an alternative fix.

Related

Is there a way to use an older version of Java with scala-maven-plugin

I would need to compile a legacy scala project (Scala version 2.8.0). The version is incompatible with JDK8. So I would like to ideally compile the project using JDK 7. I am looking for a configuration something like the following in maven-compiler-plugin.
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
Is there a similar configuration in scala-maven-plugin?
I have tried using "source" as suggested in the documentation of the plugin and javacargs as well. But both those options don't work.
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<recompileMode>incremental</recompileMode>
<source>1.7</source>
<target>1.7</target>
<javacArgs>
<javacArg>-source</javacArg>
<javacArg>1.7</javacArg>
<javacArg>-target</javacArg>
<javacArg>1.7</javacArg>
</javacArgs>
</configuration>
</plugin>
Does anyone know what I am doing wrong? I don't have the option of using JDK7

Mojo Codehaus Properties Plugin Alternatives

I am currently trying to work with Codehaus Mojo Properties. I only found out about it this morning.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
</plugin>
So I cant say that I am an expert on it. But when trying to build a war file I keep getting:
Caused by: org.apache.maven.plugin.MojoFailureException: Circular property definition:
My plugin configuration is:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>read-pal-properties</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}\src\main\resources\system.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
A property that fails is:
webserver.websphere=WebSphere:cell=${webserver.cell},node=${webserver.node},server=${webserver.server}
I googled a bit about it, and saw that this is a known bug. So just wanted to see if there are other plugins that do that same job.
https://github.com/mojohaus/properties-maven-plugin/issues/27
Any help would be appreciated.
If you still haven't found the answer yet after >2years, use the 1.0-alpha-2 version

maven with JDK11: javac: invalid flag: --release

I'm trying to set up a simple maven project with java 11. As I want to keep JAVA_HOME to be version 8, I'm using maven-toolchains-plugin to make maven use jdk11 for this project.
While maven successfully finds a matching toolchain for jdk-11.0.1, I keep getting " javac: invalid flag: --release". What am I doing wrong?
Here are the plugin configurations:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>11</version>
</jdk>
</toolchains>
</configuration>
</plugin>
The toolchain is defined as:
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<id>JavaSE-1.11</id>
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk-11.0.1\bin</jdkHome>
</configuration>
<toolchain>
As I found out, the configuration is just fine. The problem was that jdkHome in toolchains.xml was pointing to the \jdk-11.0.1\bin direction instead of \jdk-11.0.1 directly..... Using <jdkHome>C:\Program Files\Java\jdk-11.0.1</jdkHome> solves the problem..
Changing the jdk version should fix the problem mostly. Replace
<version>1.11</version>
with
<version>11</version>
Do ensure though that your maven is configured with JDK-11 using the command mvn -version and confirming the Java version there. You can also verify the toolchains.xml JDK configured as well.
In case you're trying to compile using different versions of the compiler, you need to ensure executions under the maven-compiler-plugin as:
<executions>
<execution>
<id>java11</id>
<phase>none</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>11</release>
<jdkToolchain>
<version>11</version>
</jdkToolchain>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
</compileSourceRoots>
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/11</outputDirectory>
</configuration>
</execution>
</executions>
Here is the sample pom.xml referred for the above.

Maven pom plugin not executing on build

I'm practicing Maven and I've hit a wall. I've installed the PlantUml plugin on IntelliJ and I'm trying to set it up so that it always generates a new image from the source file on compile time. I'm using this plugin to generate the image, and I've configured the pom.xml file as follows:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.jeluard</groupId>
<artifactId>plantuml-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>GeneratePlantUml</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/images</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<sourceFiles>
<directory>${basedir}/plantuml</directory>
<includes>
<include>TestGeneratorDiagram.puml</include>
</includes>
</sourceFiles>
<outputDirectory>${basedir}/images</outputDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>8031</version>
</dependency>
</dependencies>
</plugin>
<plugins>
</pluginManagement>
<build>
This works fine when I use a terminal command where I specify the goal:
mvn compile com.github.jeluard:plantuml-maven-plugin:generate
However, it doesn't work if I just write:
mvn compile
Which, as far as I know, should also work. I've tried setting the phase on compile but it didn't change anything. I've searched for hours now for a solution but I haven't found one. Does anyone know how I can force the plugin to generate a new image on compile time by configuring the pom?
You have put your configuration into pluginManagement. You needs to put it into plugins (outside pluginManagement).
The pluginManagement is just to override/specify configuration and version numbers.
Have a look at Maven: What is pluginManagement?
your plugin and your execution is configure à the "generate-resources" phase and not at the compile phase like you want.
See this link to more detail on phase.
change this:
<execution>
<id>GeneratePlantUml</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
to this
<execution>
<id>GeneratePlantUml</id>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
It must works.

How to determine version of the actually installed maven-gpg-plugin?

As documented on this page, here is the maven-gpg-plugin block as used in the POM for all three of my projects:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
How can you tell the version of this plugin that is actually installed on my computer? Is the fact that 1.5 seems to work good enough?
Thanks.
there could be multiple installed you are interested to know which one is being used effectively you need
mvn help:effective-pom
this will render effective pom.xml and you can figure out which version is effective

Categories

Resources