You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Jan Monterrubio (Jira)" <ji...@apache.org> on 2020/10/25 17:16:00 UTC

[jira] [Updated] (MNG-7006) Report plugin not configured correctly according to documentation

     [ https://issues.apache.org/jira/browse/MNG-7006?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jan Monterrubio updated MNG-7006:
---------------------------------
    Priority: Minor  (was: Major)

> Report plugin not configured correctly according to documentation
> -----------------------------------------------------------------
>
>                 Key: MNG-7006
>                 URL: https://issues.apache.org/jira/browse/MNG-7006
>             Project: Maven
>          Issue Type: Bug
>          Components: Sites &amp; Reporting
>    Affects Versions: 3.6.3
>            Reporter: Jan Monterrubio
>            Priority: Minor
>
> Using the referenced documentation: [http://maven.apache.org/guides/mini/guide-configuring-plugins.html#configuring-reporting-plugins |http://maven.apache.org/guides/mini/guide-configuring-plugins.html#configuring-reporting-plugins]
> I believe there is an issue with the way the report mojo is configured when invoking the site vs invoking the goal directly.
> h1. Reproducible Sample
> A minimal plugin that reproduces the issue can be found here: [https://github.com/AnEmortalKid/sample-report-plugin] , a project that uses the plugin can be found in the same repository under src/test/resources/it/config-print
>  
> h3. Setup
> Mojo
> {code:java}
>  @Mojo(name = "word", defaultPhase = LifecyclePhase.SITE, threadSafe = true)public class SampleReport extends AbstractMavenReport {
>   @Parameter private String word;
>   protected void executeReport(Locale locale) throws MavenReportException {    getLog().info("Word is " + word);  }
>   public String getOutputName() {    return "word.html";  }
>   public String getName(Locale locale) {    return "word";  }
>   public String getDescription(Locale locale) {    return "Prints a word from config";  }}{code}
> h3. Project
> {code:java}
>  <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>io.anemortalkid</groupId>
>     <artifactId>config-print</artifactId>
>     <version>1.0.0-SNAPSHOT</version>
>     <properties>
>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>     </properties>
>     <build>
>         <pluginManagement>
>             <plugins>
>                 <plugin>
>                     <groupId>io.anemortalkid</groupId>
>                     <artifactId>sample-report-plugin</artifactId>
>                     <version>1.0.0-SNAPSHOT</version>
>                 </plugin>
>                 <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-site-plugin</artifactId>
>                     <version>3.9.0</version>
>                 </plugin>
>             </plugins>
>         </pluginManagement>
>         <plugins>
>             <plugin>
>                 <groupId>io.anemortalkid</groupId>
>                 <artifactId>sample-report-plugin</artifactId>
>                 <configuration>
>                     <word>fromBuild</word>
>                 </configuration>
>             </plugin>
>         </plugins>
>     </build>
>     <reporting>
>         <plugins>
>             <plugin>
>                 <groupId>io.anemortalkid</groupId>
>                 <artifactId>sample-report-plugin</artifactId>
>                 <configuration>
>                     <word>fromReporting</word>
>                 </configuration>
>             </plugin>
>         </plugins>
>     </reporting>
> </project>{code}
> h2. Site Invocation
>  
> Invoking the site phase yields the correct behavior according to the doc: 
> "It uses *only* the parameters defined in the <configuration> element of each reporting Plugin specified in the <reporting> element, i.e. {{site}} always *ignores* the parameters defined in the <configuration> element of each plugin specified in <build>."
> {code:java}
> [INFO] --- maven-site-plugin:3.9.0:site (default-site) @ config-print ---
> [INFO] configuring report plugin io.anemortalkid:sample-report-plugin:1.0.0-SNAPSHOT
> [INFO] 1 report detected for sample-report-plugin:1.0.0-SNAPSHOT: word
> [WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
> [WARNING] 
> [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
> [WARNING] 
> [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
> [INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1
> [INFO] 15 reports detected for maven-project-info-reports-plugin:3.1.1: ci-management, dependencies, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing-lists, modules, plugin-management, plugins, scm, summary, team
> [INFO] Rendering site with default locale English (en)
> [WARNING] No project URL defined - decoration links will not be relativized!
> [INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.3 skin.
> [INFO] Generating "word" report          --- sample-report-plugin:1.0.0-SNAPSHOT:word
> [INFO] Word is fromReporting
> [INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:3.1.1:dependency-info
> [INFO] Generating "About" report         --- maven-project-info-reports-plugin:3.1.1:index
> [INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:3.1.1:plugin-management
> [INFO] Generating "Plugins" report       --- maven-project-info-reports-plugin:3.1.1:plugins
> [INFO] Generating "Summary" report       --- maven-project-info-reports-plugin:3.1.1:summary
> [INFO] ------------------------------------------------------------------------{code}
> h2. 
> Direct Invocation
> {code:java}
> mvn sample-report:word
> [INFO] Scanning for projects...
> [INFO] 
> [INFO] --------------------< io.anemortalkid:config-print >--------------------
> [INFO] Building config-print 1.0.0-SNAPSHOT
> [INFO] --------------------------------[ jar ]---------------------------------
> [INFO] 
> [INFO] --- sample-report-plugin:1.0.0-SNAPSHOT:word (default-cli) @ config-print ---
> [INFO] Word is fromBuild
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time:  1.124 s
> [INFO] Finished at: 2020-10-24T15:31:14-05:00
> [INFO] ------------------------------------------------------------------------ {code}
> To me, this seems to contradict the documentation:
> "It uses *firstly* the parameters defined in the <configuration> element of each reporting Plugin specified in the <reporting> element; if a parameter is not found, it will look up to a parameter defined in the <configuration> element of each plugin specified in <build>."
>  
> Since I defined the configuration in the reporting element. The *word* parameter should be found from that section, and be "fromReporting" instead of from build.
> If I remove the reporting configuration, the behavior then WOULD be expected (read from build since reporting is null).
> *Effective Pom*
> **
> {code:java}
> <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>io.anemortalkid</groupId>
>   <artifactId>config-print</artifactId>
>   <version>1.0.0-SNAPSHOT</version>
>   <properties>
>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>   </properties>
>   <repositories>
>     <repository>
>       <snapshots>
>         <enabled>false</enabled>
>       </snapshots>
>       <id>central</id>
>       <name>Central Repository</name>
>       <url>https://repo.maven.apache.org/maven2</url>
>     </repository>
>   </repositories>
>   <pluginRepositories>
>     <pluginRepository>
>       <releases>
>         <updatePolicy>never</updatePolicy>
>       </releases>
>       <snapshots>
>         <enabled>false</enabled>
>       </snapshots>
>       <id>central</id>
>       <name>Central Repository</name>
>       <url>https://repo.maven.apache.org/maven2</url>
>     </pluginRepository>
>   </pluginRepositories>
>   <build>
>     <sourceDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/main/java</sourceDirectory>
>     <scriptSourceDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/main/scripts</scriptSourceDirectory>
>     <testSourceDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/test/java</testSourceDirectory>
>     <outputDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/classes</outputDirectory>
>     <testOutputDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/test-classes</testOutputDirectory>
>     <resources>
>       <resource>
>         <directory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/main/resources</directory>
>       </resource>
>     </resources>
>     <testResources>
>       <testResource>
>         <directory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/test/resources</directory>
>       </testResource>
>     </testResources>
>     <directory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target</directory>
>     <finalName>config-print-1.0.0-SNAPSHOT</finalName>
>     <pluginManagement>
>       <plugins>
>         <plugin>
>           <artifactId>maven-antrun-plugin</artifactId>
>           <version>1.3</version>
>         </plugin>
>         <plugin>
>           <artifactId>maven-assembly-plugin</artifactId>
>           <version>2.2-beta-5</version>
>         </plugin>
>         <plugin>
>           <artifactId>maven-dependency-plugin</artifactId>
>           <version>2.8</version>
>         </plugin>
>         <plugin>
>           <artifactId>maven-release-plugin</artifactId>
>           <version>2.5.3</version>
>         </plugin>
>         <plugin>
>           <groupId>io.anemortalkid</groupId>
>           <artifactId>sample-report-plugin</artifactId>
>           <version>1.0.0-SNAPSHOT</version>
>         </plugin>
>         <plugin>
>           <artifactId>maven-site-plugin</artifactId>
>           <version>3.9.0</version>
>         </plugin>
>       </plugins>
>     </pluginManagement>
>     <plugins>
>       <plugin>
>         <groupId>io.anemortalkid</groupId>
>         <artifactId>sample-report-plugin</artifactId>
>         <version>1.0.0-SNAPSHOT</version>
>         <configuration>
>           <word>fromBuild</word>
>         </configuration>
>       </plugin>
>       <plugin>
>         <artifactId>maven-clean-plugin</artifactId>
>         <version>2.5</version>
>         <executions>
>           <execution>
>             <id>default-clean</id>
>             <phase>clean</phase>
>             <goals>
>               <goal>clean</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-resources-plugin</artifactId>
>         <version>2.6</version>
>         <executions>
>           <execution>
>             <id>default-testResources</id>
>             <phase>process-test-resources</phase>
>             <goals>
>               <goal>testResources</goal>
>             </goals>
>           </execution>
>           <execution>
>             <id>default-resources</id>
>             <phase>process-resources</phase>
>             <goals>
>               <goal>resources</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-jar-plugin</artifactId>
>         <version>2.4</version>
>         <executions>
>           <execution>
>             <id>default-jar</id>
>             <phase>package</phase>
>             <goals>
>               <goal>jar</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <version>3.1</version>
>         <executions>
>           <execution>
>             <id>default-compile</id>
>             <phase>compile</phase>
>             <goals>
>               <goal>compile</goal>
>             </goals>
>           </execution>
>           <execution>
>             <id>default-testCompile</id>
>             <phase>test-compile</phase>
>             <goals>
>               <goal>testCompile</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-surefire-plugin</artifactId>
>         <version>2.12.4</version>
>         <executions>
>           <execution>
>             <id>default-test</id>
>             <phase>test</phase>
>             <goals>
>               <goal>test</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-install-plugin</artifactId>
>         <version>2.4</version>
>         <executions>
>           <execution>
>             <id>default-install</id>
>             <phase>install</phase>
>             <goals>
>               <goal>install</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-deploy-plugin</artifactId>
>         <version>2.7</version>
>         <executions>
>           <execution>
>             <id>default-deploy</id>
>             <phase>deploy</phase>
>             <goals>
>               <goal>deploy</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <artifactId>maven-site-plugin</artifactId>
>         <version>3.9.0</version>
>         <executions>
>           <execution>
>             <id>default-site</id>
>             <phase>site</phase>
>             <goals>
>               <goal>site</goal>
>             </goals>
>             <configuration>
>               <outputDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site</outputDirectory>
>               <reportPlugins>
>                 <reportPlugin>
>                   <groupId>io.anemortalkid</groupId>
>                   <artifactId>sample-report-plugin</artifactId>
>                   <configuration>
>                     <word>fromReporting</word>
>                   </configuration>
>                 </reportPlugin>
>                 <reportPlugin>
>                   <groupId>org.apache.maven.plugins</groupId>
>                   <artifactId>maven-project-info-reports-plugin</artifactId>
>                 </reportPlugin>
>               </reportPlugins>
>             </configuration>
>           </execution>
>           <execution>
>             <id>default-deploy</id>
>             <phase>site-deploy</phase>
>             <goals>
>               <goal>deploy</goal>
>             </goals>
>             <configuration>
>               <outputDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site</outputDirectory>
>               <reportPlugins>
>                 <reportPlugin>
>                   <groupId>io.anemortalkid</groupId>
>                   <artifactId>sample-report-plugin</artifactId>
>                   <configuration>
>                     <word>fromReporting</word>
>                   </configuration>
>                 </reportPlugin>
>                 <reportPlugin>
>                   <groupId>org.apache.maven.plugins</groupId>
>                   <artifactId>maven-project-info-reports-plugin</artifactId>
>                 </reportPlugin>
>               </reportPlugins>
>             </configuration>
>           </execution>
>         </executions>
>         <configuration>
>           <outputDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site</outputDirectory>
>           <reportPlugins>
>             <reportPlugin>
>               <groupId>io.anemortalkid</groupId>
>               <artifactId>sample-report-plugin</artifactId>
>               <configuration>
>                 <word>fromReporting</word>
>               </configuration>
>             </reportPlugin>
>             <reportPlugin>
>               <groupId>org.apache.maven.plugins</groupId>
>               <artifactId>maven-project-info-reports-plugin</artifactId>
>             </reportPlugin>
>           </reportPlugins>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
>   <reporting>
>     <outputDirectory>/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site</outputDirectory>
>     <plugins>
>       <plugin>
>         <groupId>io.anemortalkid</groupId>
>         <artifactId>sample-report-plugin</artifactId>
>         <configuration>
>           <word>fromReporting</word>
>         </configuration>
>       </plugin>
>     </plugins>
>   </reporting>
> </project> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)