Use project name in generated Apache NOTICE - #830
Conversation
690340b to
85919d4
Compare
85919d4 to
d0bc690
Compare
|
Rebased. |
Default an unset ApacheNoticeResourceTransformer project name from MavenProject while preserving explicit configuration and the empty fallback. Fixes apache#742.
d0bc690 to
3fb4cda
Compare
| throw new MojoExecutionException( | ||
| "Failed to create shaded artifact: parameter transformers contains null (double-check XML attribute)"); | ||
| } | ||
| if (transformer instanceof ApacheNoticeResourceTransformer) { |
There was a problem hiding this comment.
might be necessary, but it would be cleaner if we could figure out some way to do this that doesn't require instanceof and casting.
| * | ||
| * @param projectName the Maven project name | ||
| */ | ||
| public void setProjectNameIfUnset(String projectName) { |
There was a problem hiding this comment.
why "if unset"? why not just set project name?
There was a problem hiding this comment.
Because the field can be set via XML in the POM file, too. That takes precedence. If it is however not set via XML in POM, it will be set here. Thus if unset.
There was a problem hiding this comment.
This still makes me queasy. My gut is that if someone calls this method, the project name should be set.
Even if we keep the behavior as it, we need a better name. setDefaultProjectName? setFallbackProjectName? maybe something else.
There was a problem hiding this comment.
The current name is descriptive. It does not need a different name.
Summary
Use the Maven project name as the default project name in notices generated by
ApacheNoticeResourceTransformer.The transformer previously initialized
projectNameto an empty string and themojo never supplied the injected
MavenProject. Consequently, configuring thetransformer without an explicit
<projectName>produced a blank generatedNOTICE header even when the POM had a nonblank
<name>.ShadeMojonow suppliesMavenProject#getName()when the transformer projectname is unset and the Maven project name is neither null nor blank. Explicit
transformer configuration remains authoritative, and a missing or blank Maven
project name preserves the previous empty behavior.
The change includes unit coverage for the fallback rules, a failing-first
integration test for the generated NOTICE, and documentation of the default.
Fixes #742.
Validation
mvn -Prun-its clean verify: 74 unit tests and 84 integration projectspassed; two projects were skipped by their JRE-version conditions.
mvn test: 74 tests passed.generated the expected NOTICE header.
mvn sitepassed.Following this checklist to help us incorporate your
contribution quickly and easily:
Make sure there is a JIRA issue filed
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
Each commit in the pull request should have a meaningful subject line and body.
Format the pull request title like
[MSHADE-XXX] - Fixes bug in ApproximateQuantiles,where you replace
MSHADE-XXXwith the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
Run
mvn clean verifyto make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
You have run the integration tests successfully (
mvn -Prun-its clean verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.