How can I disable the Maven Javadoc plugin from the command line?
Asked Answered
C

7

294

In pom.xml I have declaration like this

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

is there any way to turn that off from command line?

I do know I can extract that into a profile, but that is not what I want.

Cowgirl answered 14/9, 2011 at 6:15 Comment(0)
O
560

The Javadoc generation can be skipped by setting the property maven.javadoc.skip to true [1], i.e.

-Dmaven.javadoc.skip=true

(and not false)

Overture answered 20/2, 2012 at 11:22 Comment(3)
See @Christoph-Tobias Schenke answer for approach to take with child modules.Fundamental
This argument can also be set directly in jenkins to avoid this problem (in Global MAVEN_OPTS defined in Configure System)Yasui
This didn't work for me, but learned that when you use the maven release plugin you need to pass this parameter differently. This worked: mvn release:perform -Darguments="-Dmaven.javadoc.skip=true".Diopside
C
234

It seems, that the simple way

-Dmaven.javadoc.skip=true

does not work with the release-plugin. in this case you have to pass the parameter as an "argument"

mvn release:perform -Darguments="-Dmaven.javadoc.skip=true"
Consecrate answered 5/1, 2016 at 13:44 Comment(5)
If you need to add two arguments you can separate them with a space like this -Darguments="-DskipTests -Dmaven.javadoc.skip=true"Naamana
It also works to add these to the release plugin config in the root-level pom.xml: <configuration><arguments>-DskipTests -Dmaven.javadoc.skip=true</arguments></configuration>Triage
In addition, skipTests comes in a stronger flavor that also skips compilation of tests: -Dmaven.tests.skip=trueTriage
Wow, why does the maven release plugin do this...totally lost some time on this oneFogarty
somehow this didn't work for meCivilization
C
146

You can use the maven.javadoc.skip property to skip execution of the plugin, going by the Mojo's javadoc. You can specify the value as a Maven property:

<properties>
    <maven.javadoc.skip>true</maven.javadoc.skip>
</properties>

or as a command-line argument: -Dmaven.javadoc.skip=true, to skip generation of the Javadocs.

Calycine answered 14/9, 2011 at 6:34 Comment(2)
This answer doesnt really answer the question, since in there it states that the switch should be done via the command line.Rationale
This is the perfect solution for a multi-module project with a few modules not generating any javadoc and causing an error otherwise.Lardon
T
25

Add to the release plugin config in the root-level pom.xml:

<configuration>
    <arguments>-Dmaven.javadoc.skip=true</arguments>
</configuration>
Triage answered 13/5, 2016 at 14:14 Comment(1)
this is not properly from command line as required by the question, but it works great if you need to disable permanently the javadoc.Fonville
H
5

Dans le pom.xml

1st option : using properties

<properties>
    <maven.javadoc.skip>true</maven.javadoc.skip> 
</properties>

2nd option : using the build > pluginManagement > plugins > plugin > configuration

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <goals>deploy</goals>
                    <arguments>-Dmaven.javadoc.skip=true</arguments>
                </configuration>
            </plugin>

3rd option : When invoking mvn (this one did not work for me)

 mvn clean install -Dmaven.javadoc.skip=true
Hamilton answered 14/10, 2022 at 6:40 Comment(0)
D
3

For newbie Powershell users it is important to know that '.' is a syntactic element of Powershell, so the switch has to be enclosed in double quotes:

mvn clean install "-Dmaven.javadoc.skip=true"

Dronski answered 2/3, 2020 at 11:53 Comment(1)
Thanks for that. I was looking for this, to setup VSCode.Rikkiriksdag
C
1

One important thing is: if you set <skip>false<skip> in configuration of maven-javadoc-plugin in pom.xml, the -Dmaven.javadoc.skip=true will not work, at least for maven-daemon(aka mvndaemon or mvnd).

Coopt answered 23/8, 2022 at 3:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.