slawekjaranowski commented on code in PR #1021:
URL: https://github.com/apache/maven-enforcer/pull/1021#discussion_r4009070387
##########
maven-enforcer-extension/src/main/java/org/apache/maven/extensions/enforcer/EnforceExtension.java:
##########
@@ -58,6 +58,14 @@ public class EnforceExtension extends
AbstractMavenLifecycleParticipant {
@Override
public void afterProjectsRead(MavenSession session) throws
MavenExecutionException {
+ String skip = session.getUserProperties().getProperty("enforcer.skip");
+ if (skip == null) {
+ skip = session.getSystemProperties().getProperty("enforcer.skip");
+ }
+ if ("true".equalsIgnoreCase(skip) || (skip != null && skip.isEmpty()))
{
+ return;
+ }
Review Comment:
**Skip projects with no POM file.** Without a POM, Maven builds the
`org.apache.maven:standalone-pom` stub and the extension attaches the execution
to it. Please guard the loop over the projects:
https://github.com/apache/maven-enforcer/blob/fa16b26747a6be503cbed7d0da50decc8a40c10e/maven-enforcer-extension/src/main/java/org/apache/maven/extensions/enforcer/EnforceExtension.java#L94
```java
for (MavenProject project : session.getProjects()) {
if (project.getFile() == null) {
continue;
}
```
This fixes the POM-less invocation in general, not only when
`-Denforcer.skip` is passed.
--
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]