Skip to content

Commit 6f30bed

Browse files
authored
[MJAVADOC-642] Make offline mode configurable (#232)
expose the offline flag as a property (and a setting).
1 parent e4023d0 commit 6f30bed

File tree

10 files changed

+269
-6
lines changed

10 files changed

+269
-6
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals= package

src/it/projects/MJAVADOC-642/pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed under the Apache License, Version 2.0 (the "License");
4+
~ you may not use this file except in compliance with the License.
5+
~ You may obtain a copy of the License at
6+
~
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
18+
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
19+
<artifactId>mjavadoc642</artifactId>
20+
<version>1.0-SNAPSHOT</version>
21+
<packaging>jar</packaging>
22+
23+
<url>https://issues.apache.org/jira/browse/MJAVADOC-642</url>
24+
25+
<properties>
26+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
27+
</properties>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<artifactId>maven-javadoc-plugin</artifactId>
33+
<version>@project.version@</version>
34+
<executions>
35+
<execution>
36+
<id>javadoc</id>
37+
<goals>
38+
<goal>jar</goal>
39+
</goals>
40+
<phase>package</phase>
41+
<configuration>
42+
<offline>true</offline>
43+
<skip>false</skip>
44+
<detectJavaApiLink>false</detectJavaApiLink>
45+
<detectOfflineLinks>false</detectOfflineLinks>
46+
<failOnWarnings>true</failOnWarnings>
47+
</configuration>
48+
</execution>
49+
</executions>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package mjavadoc642;
21+
22+
/**
23+
* This is the main class.
24+
*/
25+
public final class Main {
26+
/**
27+
* This is the main method.
28+
*
29+
* @param args The arguments
30+
* @throws Exception if something goes wrong
31+
*/
32+
public static final void main(String ... args) throws Exception {
33+
System.out.println("Hello, World!");
34+
}
35+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
def log = new File( basedir, 'build.log').text
21+
22+
assert log.count("[DEBUG] (f) offline = false") == 0
23+
assert log.count("[DEBUG] (f) offline = true") == 1
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals= -Dmaven.javadoc.offline=true package
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed under the Apache License, Version 2.0 (the "License");
4+
~ you may not use this file except in compliance with the License.
5+
~ You may obtain a copy of the License at
6+
~
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
18+
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
19+
<artifactId>mjavadoc642</artifactId>
20+
<version>1.0-SNAPSHOT</version>
21+
<packaging>jar</packaging>
22+
23+
<url>https://issues.apache.org/jira/browse/MJAVADOC-642</url>
24+
25+
<properties>
26+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
27+
</properties>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<artifactId>maven-javadoc-plugin</artifactId>
33+
<version>@project.version@</version>
34+
<executions>
35+
<execution>
36+
<id>javadoc</id>
37+
<goals>
38+
<goal>jar</goal>
39+
</goals>
40+
<phase>package</phase>
41+
<configuration>
42+
<skip>false</skip>
43+
<detectJavaApiLink>false</detectJavaApiLink>
44+
<detectOfflineLinks>false</detectOfflineLinks>
45+
<failOnWarnings>true</failOnWarnings>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package mjavadoc642;
21+
22+
/**
23+
* This is the main class.
24+
*/
25+
public final class Main {
26+
/**
27+
* This is the main method.
28+
*
29+
* @param args The arguments
30+
* @throws Exception if something goes wrong
31+
*/
32+
public static final void main(String ... args) throws Exception {
33+
System.out.println("Hello, World!");
34+
}
35+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
def log = new File( basedir, 'build.log').text
21+
22+
assert log.count("[DEBUG] (f) offline = false") == 0
23+
assert log.count("[DEBUG] (f) offline = true") == 1

src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,14 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
333333
private MojoExecution mojo;
334334

335335
/**
336-
* Specify if the Javadoc should operate in offline mode.
336+
* Specify if the Javadoc plugin should operate in offline mode. If maven is run in offline
337+
* mode (using {@code -o} or {@code --offline} on the command line), this option has no effect
338+
* and the plugin is always in offline mode.
339+
*
340+
* @since 3.6.0
337341
*/
338-
@Parameter(defaultValue = "${settings.offline}", required = true, readonly = true)
339-
private boolean isOffline;
342+
@Parameter(property = "maven.javadoc.offline", defaultValue = "false")
343+
private boolean offline;
340344

341345
/**
342346
* Specifies the Javadoc resources directory to be included in the Javadoc (i.e. package.html, images...).
@@ -1033,7 +1037,9 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
10331037
*
10341038
* <b>Notes</b>:
10351039
* <ol>
1036-
* <li>only used if {@code isOffline} is set to <code>false</code>.</li>
1040+
* <li>This option is ignored if the plugin is run in offline mode (using the {@code <offline>}
1041+
* setting or specifying {@code -o, --offline} or {@code -Dmaven.javadoc.offline=true} on the
1042+
* command line.</li>
10371043
* <li>all given links should have a fetchable <code>/package-list</code> or <code>/element-list</code>
10381044
* (since Java 10). For instance:
10391045
* <pre>
@@ -3781,7 +3787,7 @@ private void addLinkArguments(List<String> arguments) throws MavenReportExceptio
37813787
continue;
37823788
}
37833789

3784-
if (isOffline && !link.startsWith("file:")) {
3790+
if ((settings.isOffline() || offline) && !link.startsWith("file:")) {
37853791
continue;
37863792
}
37873793

src/test/resources/unit/custom-configuration/custom-configuration-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ under the License.
9898
<header>MAVEN JAVADOC PLUGIN TEST</header>
9999
<footer>MAVEN JAVADOC PLUGIN TEST FOOTER</footer>
100100
<locale>en_US</locale>
101-
<isOffline>true</isOffline>
101+
<offline>true</offline>
102102
<excludePackageNames>*.exclude2:custom.configuration.exclude1.*</excludePackageNames>
103103
<debug>true</debug>
104104
<failOnError>true</failOnError>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy