You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/05/23 18:36:00 UTC

[jira] [Commented] (MPLUGIN-396) Allow only @Deprecated annotation without @deprecated javadoc tag

    [ https://issues.apache.org/jira/browse/MPLUGIN-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17541091#comment-17541091 ] 

ASF GitHub Bot commented on MPLUGIN-396:
----------------------------------------

michael-o commented on code in PR #87:
URL: https://github.com/apache/maven-plugin-tools/pull/87#discussion_r879760810


##########
maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/invoker.properties:
##########
@@ -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.
+
+invoker.maven.version = 3.0+
+invoker.goals.1 = clean install -DskipTests

Review Comment:
   Why skip if it is not there?



##########
maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/verify.groovy:
##########
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+expected = new File( basedir, "expected-help.txt" ).text.trim().replace( "\r", "" )
+
+log = new File( basedir, "help.log" ).text.replace( "\r", "" )

Review Comment:
   If for both, Git will do system LS and Java as well, why replace?



##########
maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java:
##########
@@ -271,6 +271,12 @@ protected void analyzeVisitors( MojoClassVisitor mojoClassVisitor )
             {
                 MojoAnnotationContent mojoAnnotationContent = new MojoAnnotationContent();
                 populateAnnotationContent( mojoAnnotationContent, mojoAnnotationVisitor );
+
+                if ( mojoClassVisitor.getAnnotationVisitor( Deprecated.class ) != null )
+                {
+                    mojoAnnotationContent.setDeprecated( "" );

Review Comment:
   One should use `StringUtils.EMPTY` or alike to indicate that this is not a typo or bug.



##########
maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/invoker.properties:
##########
@@ -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.
+
+invoker.maven.version = 3.0+
+invoker.goals.1 = clean install -DskipTests
+invoker.goals.2 = org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
+invoker.goals.3 = --log-file help.log org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
+# --log-file option is only supported by Maven 3
+invoker.maven.version = 3.0+

Review Comment:
   Does this project work with Maven 2 as well?



##########
maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/expected-help.txt:
##########
@@ -0,0 +1,25 @@
+[INFO] help 1.0-SNAPSHOT
+  Tests generation and compilation of the help mojo.
+
+help:test
+  Deprecated. No reason given
+
+  MOJO-DESCRIPTION. Some 'quotation' marks and backslashes '\\', some important
+  javadoc
+  and an inline link to AnotherMojo.
+
+  Available parameters:
+
+    defaultParam (Default: escape\backslash)
+      This parameter uses 'quotation' marks and backslashes '\\' in its
+      description. Those characters must be escaped in Java string literals.
+
+    deprecatedParam
+      Deprecated. No reason given
+
+      This parameter is deprecated.

Review Comment:
   This is weird. I see basically the same information twice, no?



##########
maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/pom.xml:
##########
@@ -0,0 +1,87 @@
+<?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.its.plugin</groupId>
+  <artifactId>help</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <description>
+    Tests generation and compilation of the help mojo.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>@mavenVersion@</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>3.0.1</version>

Review Comment:
   Please use 3.3.1 to stay up to date



##########
maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java:
##########
@@ -289,10 +295,15 @@ protected void analyzeVisitors( MojoClassVisitor mojoClassVisitor )
             {
                 ParameterAnnotationContent parameterAnnotationContent =
                     new ParameterAnnotationContent( mojoFieldVisitor.getFieldName(), mojoFieldVisitor.getClassName() );
-                if ( mojoFieldVisitor.getMojoAnnotationVisitor() != null )
+
+                Map<String, MojoAnnotationVisitor> annotationVisitorMap = mojoFieldVisitor.getAnnotationVisitorMap();
+                MojoAnnotationVisitor fieldAnnotationVisitor = annotationVisitorMap.get( Parameter.class.getName() );
+
+                populateAnnotationContent( parameterAnnotationContent, fieldAnnotationVisitor );
+
+                if ( annotationVisitorMap.containsKey( Deprecated.class.getName() ) )
                 {
-                    populateAnnotationContent( parameterAnnotationContent,
-                                               mojoFieldVisitor.getMojoAnnotationVisitor() );
+                    parameterAnnotationContent.setDeprecated( "" );

Review Comment:
   same here.





> Allow only @Deprecated annotation without @deprecated javadoc tag
> -----------------------------------------------------------------
>
>                 Key: MPLUGIN-396
>                 URL: https://issues.apache.org/jira/browse/MPLUGIN-396
>             Project: Maven Plugin Tools
>          Issue Type: Improvement
>            Reporter: Slawomir Jaranowski
>            Priority: Major
>
> Currently to effective deprecate Mojo parameters we must define both {{@Deprecated}} annotation and {{@deprecated}} javadoc tag.
> Definition must be:
> {code:java}
>     /**
>      * A parameter description
>      *
>      * @deprecated
>      */
>     @Deprecated
>     @Parameter
>     private String param;
> {code}
> should be allowed as:
> {code:java}
>     @Deprecated
>     @Parameter
>     private String param;
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)