kratos0718 opened a new pull request, #325:
URL: https://github.com/apache/maven-source-plugin/pull/325

   Fixes #306.
   
   ## Problem
   
   `AggregatorSourceJarMojo.doExecute()` packages sources only when the project 
uses `pom` packaging:
   
   ```java
   if (Type.POM.equals(getProject().getPackaging().type().id())) {
       packageSources(reactorProjects);
   }
   ```
   
   With any other packaging it returns silently. No source JAR is produced and 
the user gets no indication why — which, as the issue notes, is a plausible 
outcome of a misleading build or configuration even though `@Mojo(aggregator = 
true)` normally implies `pom`.
   
   ## Change
   
   Adds an `else` branch that logs a warning naming the goal, the required 
packaging, and the project's actual packaging:
   
   ```
   [WARNING] Not packaging aggregated sources: the aggregate goal requires "pom"
   packaging, but this project uses "jar" packaging.
   ```
   
   The goal name is now a constant shared by the `@Mojo` annotation and the 
message, so the two cannot drift apart.
   
   ## On warning vs failing
   
   @elharo asked in the issue whether this should fail rather than log. I went 
with a warning, for the reason discussed there: a non-pom aggregator run 
**succeeds today**, so failing would turn currently-green builds red without 
any change on the user's side, and the people most likely to hit it are exactly 
those with an incidental binding they never noticed. The complaint in the issue 
is diagnosability, which the warning resolves fully.
   
   If the project would rather treat it as an outright misconfiguration, I am 
happy to switch this to a failure — I would just suggest tying that to a major 
version. Say the word and I will push the change.
   
   ## Tests
   
   `AggregatorSourceJarMojoTest` adds two cases:
   
   - `warnsWhenPackagingIsNotPom` — asserts the warning is emitted and contains 
the goal, the required packaging and the actual packaging
   - `doesNotWarnWhenPackagingIsPom` — asserts no warning on a legitimate `pom` 
run, so the change cannot over-correct into warning on valid builds
   
   ```
   Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   Behaviour for `pom` packaging is unchanged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to