[ https://issues.apache.org/jira/browse/MNG-7754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17708753#comment-17708753 ]
ASF GitHub Bot commented on MNG-7754: ------------------------------------- michael-o commented on code in PR #1079: URL: https://github.com/apache/maven/pull/1079#discussion_r1158205345 ########## maven-core/src/main/java/org/apache/maven/plugin/internal/MavenMixedDependenciesValidator.java: ########## @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugin.internal; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.PluginValidationManager; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.codehaus.plexus.component.repository.ComponentDependency; + +/** + * Detects mixed Maven versions in plugins. + * + * @since 3.9.2 + */ +@Singleton +@Named +class MavenMixedDependenciesValidator extends AbstractMavenPluginDependenciesValidator { + + @Inject + MavenMixedDependenciesValidator(PluginValidationManager pluginValidationManager) { + super(pluginValidationManager); + } + + @Override + protected void doValidate(MavenSession mavenSession, MojoDescriptor mojoDescriptor) { + Set<String> mavenVersions = mojoDescriptor.getPluginDescriptor().getDependencies().stream() + .filter(d -> "org.apache.maven".equals(d.getGroupId())) + .filter(d -> !"maven-archiver".equals(d.getArtifactId())) + .map(ComponentDependency::getVersion) + .collect(Collectors.toSet()); + + if (mavenVersions.size() > 1) { + pluginValidationManager.reportPluginValidationIssue( + mavenSession, mojoDescriptor, "Plugin mixes multiple Maven versions: " + mavenVersions); + } Review Comment: Now I see, from the message it is hard to derive that. > Improvement and extension of plugin validation > ---------------------------------------------- > > Key: MNG-7754 > URL: https://issues.apache.org/jira/browse/MNG-7754 > Project: Maven > Issue Type: Task > Components: Core > Affects Versions: 3.9.1 > Reporter: Tamas Cservenak > Priority: Major > Fix For: 3.9.2, 4.0.0-alpha-6, 4.0.0 > > > Some users when see following warning: > {noformat} > [INFO] --- remote-resources:1.7.0:process (process-resource-bundles) @ maven > --- > [WARNING] Parameter 'localRepository' is deprecated core expression; Avoid > use of ArtifactRepository type. If you need access to local repository, > switch to '${repositorySystemSession}' expression and get LRM from it > instead. {noformat} > on their console, immediately grep their {{$HOME}} to find out that they DO > HAVE afore mentioned string present in their {{{}settings.xml{}}}, and then > scratch their head how to get rid of it. > Hence, we should improve error message – at least add some clue that message > targets given Mojo developers (as message appears immediately under Mojo > execution log message) and not users. Best users could do is nag Mojo > developers, and not us, to make message disappear. > Improvements: > * report at end, instead multiple times same warning (for reactor builds) > * possibility to suppress validation > * new check: maven-compat, maven2, p-c-d, mixed maven verions,, wrong scopes > (similar as m-p-p does on build time) -- This message was sent by Atlassian Jira (v8.20.10#820010)