[MNGSITE-440] Report plugin not configured correctly according to documentation
- Dominant language
- Java
- Stars
- 123
- Forks
- 301
- Avg merge
- 16h 59m
- Merged PRs (30d)
- 32
Description
**[Jan Monterrubio](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=anemortalkid)** opened **[MNGSITE-440](https://issues.apache.org/jira/browse/MNGSITE-440?redirect=false)** and commented
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.
# 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
### Setup
Mojo
```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"; }}
```
### Project
```java
4.0.0
io.anemortalkid
config-print
1.0.0-SNAPSHOT
UTF-8
io.anemortalkid
sample-report-plugin
1.0.0-SNAPSHOT
org.apache.maven.plugins
maven-site-plugin
3.9.0
io.anemortalkid
sample-report-plugin
fromBuild
io.anemortalkid
sample-report-plugin
fromReporting
```
## Site Invocation
Invoking the site phase yields the correct behavior according to the doc:
"It uses **only** the parameters defined in the \ element of each reporting Plugin specified in the \ element, i.e. `site` always **ignores** the parameters defined in the \ element of each plugin specified in \."
```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] ------------------------------------------------------------------------
```
##
Direct Invocation
```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] ------------------------------------------------------------------------
```
To me, this seems to contradict the documentation:
"It uses **firstly** the parameters defined in the \ element of each reporting Plugin specified in the \ element; if a parameter is not found, it will look up to a parameter defined in the \ element of each plugin specified in \."
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**
**
```java
4.0.0
io.anemortalkid
config-print
1.0.0-SNAPSHOT
UTF-8
false
central
Central Repository
https://repo.maven.apache.org/maven2
never
false
central
Central Repository
https://repo.maven.apache.org/maven2
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/main/java
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/main/scripts
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/test/java
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/classes
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/test-classes
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/main/resources
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/src/test/resources
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target
config-print-1.0.0-SNAPSHOT
maven-antrun-plugin
1.3
maven-assembly-plugin
2.2-beta-5
maven-dependency-plugin
2.8
maven-release-plugin
2.5.3
io.anemortalkid
sample-report-plugin
1.0.0-SNAPSHOT
maven-site-plugin
3.9.0
io.anemortalkid
sample-report-plugin
1.0.0-SNAPSHOT
fromBuild
maven-clean-plugin
2.5
default-clean
clean
clean
maven-resources-plugin
2.6
default-testResources
process-test-resources
testResources
default-resources
process-resources
resources
maven-jar-plugin
2.4
default-jar
package
jar
maven-compiler-plugin
3.1
default-compile
compile
compile
default-testCompile
test-compile
testCompile
maven-surefire-plugin
2.12.4
default-test
test
test
maven-install-plugin
2.4
default-install
install
install
maven-deploy-plugin
2.7
default-deploy
deploy
deploy
maven-site-plugin
3.9.0
default-site
site
site
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site
io.anemortalkid
sample-report-plugin
fromReporting
org.apache.maven.plugins
maven-project-info-reports-plugin
default-deploy
site-deploy
deploy
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site
io.anemortalkid
sample-report-plugin
fromReporting
org.apache.maven.plugins
maven-project-info-reports-plugin
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site
io.anemortalkid
sample-report-plugin
fromReporting
org.apache.maven.plugins
maven-project-info-reports-plugin
/REDACTED/sample-report-plugin/src/test/resources/it/config-print/target/site
io.anemortalkid
sample-report-plugin
fromReporting
```
---
**Issue Links:**
- [MNGSITE-393](https://issues.apache.org/jira/browse/MNGSITE-393) Remove references to Maven 2.x
2 votes, 3 watchers
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the referenced plugin-configuration guide and reproduce the behavior using the linked sample-report-plugin project, especially src/test/resources/it/config-print. Compare the site phase with direct sample-report-plugin:word invocation and trace how each reads the build and reporting configurations. Done means site uses fromReporting while direct invocation continues to use fromBuild, with coverage for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100