261

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
  • 3,875
  • 7
  • 48
  • 76
IAdapter
  • 55,820
  • 69
  • 166
  • 236

5 Answers5

494

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
  • 3,875
  • 7
  • 48
  • 76
mswientek
  • 4,980
  • 1
  • 14
  • 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
  • 22
    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
206

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"
  • 9
    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
  • 4
    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
  • 1
    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
  • Wow, why does the maven release plugin do this...totally lost some time on this one – jediwompa Oct 16 '20 at 19:48
130

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
  • 73,934
  • 32
  • 166
  • 212
Vineet Reynolds
  • 72,899
  • 16
  • 143
  • 173
25

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

<configuration>
    <arguments>-Dmaven.javadoc.skip=true</arguments>
</configuration>
nclark
  • 955
  • 1
  • 9
  • 16
  • 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. – Lorenzo Sciuto Apr 09 '18 at 09:41
2

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
  • 29
  • 1