Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MJAVADOC-642] Make offline mode configurable #232

Merged
merged 1 commit into from Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/it/projects/MJAVADOC-642/invoker.properties
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

invoker.goals= package
53 changes: 53 additions & 0 deletions src/it/projects/MJAVADOC-642/pom.xml
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc642</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<url>https://issues.apache.org/jira/browse/MJAVADOC-642</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>javadoc</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<offline>true</offline>
<skip>false</skip>
<detectJavaApiLink>false</detectJavaApiLink>
<detectOfflineLinks>false</detectOfflineLinks>
<failOnWarnings>true</failOnWarnings>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
35 changes: 35 additions & 0 deletions src/it/projects/MJAVADOC-642/src/main/java/mjavadoc642/Main.java
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package mjavadoc642;

/**
* This is the main class.
*/
public final class Main {
/**
* This is the main method.
*
* @param args The arguments
* @throws Exception if something goes wrong
*/
public static final void main(String ... args) throws Exception {
System.out.println("Hello, World!");
}
}
23 changes: 23 additions & 0 deletions src/it/projects/MJAVADOC-642/verify.groovy
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

def log = new File( basedir, 'build.log').text

assert log.count("[DEBUG] (f) offline = false") == 0
assert log.count("[DEBUG] (f) offline = true") == 1
18 changes: 18 additions & 0 deletions src/it/projects/MJAVADOC-642_cmdline/invoker.properties
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

invoker.goals= -Dmaven.javadoc.offline=true package
52 changes: 52 additions & 0 deletions src/it/projects/MJAVADOC-642_cmdline/pom.xml
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc642</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<url>https://issues.apache.org/jira/browse/MJAVADOC-642</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>javadoc</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<skip>false</skip>
<detectJavaApiLink>false</detectJavaApiLink>
<detectOfflineLinks>false</detectOfflineLinks>
<failOnWarnings>true</failOnWarnings>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package mjavadoc642;

/**
* This is the main class.
*/
public final class Main {
/**
* This is the main method.
*
* @param args The arguments
* @throws Exception if something goes wrong
*/
public static final void main(String ... args) throws Exception {
System.out.println("Hello, World!");
}
}
23 changes: 23 additions & 0 deletions src/it/projects/MJAVADOC-642_cmdline/verify.groovy
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

def log = new File( basedir, 'build.log').text

assert log.count("[DEBUG] (f) offline = false") == 0
assert log.count("[DEBUG] (f) offline = true") == 1
Expand Up @@ -333,10 +333,14 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
private MojoExecution mojo;

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

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

if (isOffline && !link.startsWith("file:")) {
if ((settings.isOffline() || offline) && !link.startsWith("file:")) {
continue;
}

Expand Down
Expand Up @@ -98,7 +98,7 @@ under the License.
<header>MAVEN JAVADOC PLUGIN TEST</header>
<footer>MAVEN JAVADOC PLUGIN TEST FOOTER</footer>
<locale>en_US</locale>
<isOffline>true</isOffline>
<offline>true</offline>
<excludePackageNames>*.exclude2:custom.configuration.exclude1.*</excludePackageNames>
<debug>true</debug>
<failOnError>true</failOnError>
Expand Down