292

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.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
IAdapter
  • 62,595
  • 73
  • 179
  • 242

7 Answers7

557

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)

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
mswientek
  • 5,602
  • 1
  • 16
  • 4
  • 1
    See @Christoph-Tobias Schenke answer for approach to take with child modules. – ecoe Jan 26 '18 at 00:30
  • This argument can also be set directly in jenkins to avoid this problem (in Global MAVEN_OPTS defined in Configure System) – King Midas Mar 28 '18 at 10:37
  • 28
    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"```. – PatS Sep 28 '18 at 01:57
233

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"
Christoph-Tobias Schenke
  • 3,250
  • 1
  • 11
  • 17
  • 11
    If you need to add two arguments you can separate them with a space like this `-Darguments="-DskipTests -Dmaven.javadoc.skip=true"` – Graham Apr 14 '16 at 20:30
  • 5
    It also works to add these to the release plugin config in the root-level pom.xml: `-DskipTests -Dmaven.javadoc.skip=true` – nclark May 11 '16 at 14:17
  • 2
    In addition, skipTests comes in a stronger flavor that also skips compilation of tests: `-Dmaven.tests.skip=true` – nclark May 11 '16 at 14:28
  • 2
    Wow, why does the maven release plugin do this...totally lost some time on this one – jediwompa Oct 16 '20 at 19:48
  • somehow this didn't work for me – jediz Oct 18 '21 at 15:50
145

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.

sleske
  • 81,358
  • 34
  • 189
  • 227
Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
25

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

<configuration>
    <arguments>-Dmaven.javadoc.skip=true</arguments>
</configuration>
nclark
  • 1,022
  • 1
  • 11
  • 16
  • 2
    this is not properly from command line as required by the question, but it works great if you need to disable permanently the javadoc. – Lorenzo Sciuto Apr 09 '18 at 09:41
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"

Det
  • 39
  • 1
2

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
David
  • 67
  • 6
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).

Procrastinator
  • 2,526
  • 30
  • 27
  • 36