This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MJAVADOC-558 in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit 1b7d362e49fadd9897f0087a1928ebb6ac69a0e1 Author: rfscholte <rfscho...@apache.org> AuthorDate: Sat Dec 29 13:56:46 2018 +0100 [MJAVADOC-558] Change default value for removeUnknownThrows to true --- .../invoker.properties | 18 ++++++ .../MJAVADOC-558_fix-unknownthrows/pom.xml | 70 ++++++++++++++++++++++ .../src/main/java/com/example/FirstBug.java | 36 +++++++++++ .../MJAVADOC-558_fix-unknownthrows/verify.groovy | 26 ++++++++ .../plugins/javadoc/AbstractFixJavadocMojo.java | 6 +- 5 files changed, 154 insertions(+), 2 deletions(-) diff --git a/src/it/projects/MJAVADOC-558_fix-unknownthrows/invoker.properties b/src/it/projects/MJAVADOC-558_fix-unknownthrows/invoker.properties new file mode 100644 index 0000000..2f27cf0 --- /dev/null +++ b/src/it/projects/MJAVADOC-558_fix-unknownthrows/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=javadoc:fix compile javadoc:javadoc diff --git a/src/it/projects/MJAVADOC-558_fix-unknownthrows/pom.xml b/src/it/projects/MJAVADOC-558_fix-unknownthrows/pom.xml new file mode 100644 index 0000000..5060507 --- /dev/null +++ b/src/it/projects/MJAVADOC-558_fix-unknownthrows/pom.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId> + <artifactId>mjavadoc452</artifactId> + <version>1.0.0-SNAPSHOT</version> + + <url>https://issues.apache.org/jira/browse/MJAVADOC-452</url> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <force>true</force> + <ignoreClirr>true</ignoreClirr> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>3.2.2.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>3.2.2.RELEASE</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.5</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>provided</scope> + <version>2.5</version> + </dependency> + </dependencies> +</project> diff --git a/src/it/projects/MJAVADOC-558_fix-unknownthrows/src/main/java/com/example/FirstBug.java b/src/it/projects/MJAVADOC-558_fix-unknownthrows/src/main/java/com/example/FirstBug.java new file mode 100644 index 0000000..f0f0a79 --- /dev/null +++ b/src/it/projects/MJAVADOC-558_fix-unknownthrows/src/main/java/com/example/FirstBug.java @@ -0,0 +1,36 @@ +package com.example; + +/* + * 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. + */ + +/** + * <p>FirstBug class.</p> + */ +public class FirstBug { + + /** + * <p>mymethod.</p> + * + * @throws IllegalArgumentException how could this happen? + * @throws UnknownException some internal runtime exception + */ + public void mymethod() throws IllegalArgumentException { + + } +} \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-558_fix-unknownthrows/verify.groovy b/src/it/projects/MJAVADOC-558_fix-unknownthrows/verify.groovy new file mode 100644 index 0000000..dcdfddc --- /dev/null +++ b/src/it/projects/MJAVADOC-558_fix-unknownthrows/verify.groovy @@ -0,0 +1,26 @@ +/* + * 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 file = new File( basedir, 'src/main/java/com/example/FirstBug.java' ); + +assert file.exists() + +assert 1 == file.text.count('* @throws java.lang.IllegalArgumentException how could this happen?') +// Java 8 javadoc tool will fail due to unknown reference +assert 0 == file.text.count('@throws UnknownException some internal runtime exception') diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java index a48db12..95e0863 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java @@ -315,9 +315,11 @@ public abstract class AbstractFixJavadocMojo private boolean fixMethodComment; /** - * Flag to remove throws tags from unknown classes. + * <p>Flag to remove throws tags from unknown classes.</p> + * <p><strong>NOTE:</strong>Since 3.1.0 the default value has been changed to {@code true}, + * due to JavaDoc 8 strictness. */ - @Parameter ( property = "removeUnknownThrows", defaultValue = "false" ) + @Parameter ( property = "removeUnknownThrows", defaultValue = "true" ) private boolean removeUnknownThrows; /**