[
https://issues.apache.org/jira/browse/MNG-7706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17691990#comment-17691990
]
ASF GitHub Bot commented on MNG-7706:
-------------------------------------
cstamas commented on code in PR #1009:
URL: https://github.com/apache/maven/pull/1009#discussion_r1113938714
##########
maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedCoreExpressionValidator.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.Named;
+import javax.inject.Singleton;
+
+import java.util.HashMap;
+
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+
+/**
+ * Print warnings if deprecated core parameters are used in mojo.
+ *
+ * @since 3.9.1
+ */
+@Singleton
+@Named
+class DeprecatedCoreExpressionValidator extends
AbstractMavenPluginParametersValidator {
+ private static final HashMap<String, String> DEPRECATED_CORE_PARAMETERS;
+
+ static {
+ HashMap<String, String> deprecatedCoreParameters = new HashMap<>();
+ deprecatedCoreParameters.put(
+ "localRepository", "Switch to '${repositorySystemSession}' and
get LRM from there instead.");
Review Comment:
True! Fixing this
> Deprecate 'localRepository' mojo parameter expression
> -----------------------------------------------------
>
> Key: MNG-7706
> URL: https://issues.apache.org/jira/browse/MNG-7706
> Project: Maven
> Issue Type: Improvement
> Components: Core
> Reporter: Tamas Cservenak
> Assignee: Tamas Cservenak
> Priority: Major
> Fix For: 4.0.0, 4.0.0-alpha-5, 3.9.1
>
>
> The mojo parameter expression 'localRepository' injects type
> {{ArtifactRepository}} that is part of the suite coming from Maven2 (predates
> Mercury, that was superseded by Aether, today Maven Resolver).
> The problem with this interface is that it is not compatible (nor is possible
> to adapt it) to Maven Resolver LocalRepositoryManager due lack of context.
> Also, the use of this interface in Mojos causes issues like MNG-7663, as they
> fully (and blindly) re-implement Maven local repository with *wired in*
> layout.
> Moreover, Mojos using this expression are usually dragging other (legacy)
> deprecated things as well, most typically maven-artifact-transfer, or
> maven-dependency-tree and so on, all things that predates Maven 3.1 (are done
> to "protect" from Aether package change happened between Maven 3.0 and Maven
> 3.1). Today baseline for plugins is 3.2.5, so none of these "indirection" are
> needed anymore. In fact, the use of this expression is very good sign of
> legacy and technical debt present in given plugin. And also, these plugins
> cripple Maven to adopt new features. This warning is a clear indicator for
> legacy or neglected plugins.
> The type {{ArtifactRepository}} is used in Maven internally (most in
> maven-compat, a bit less in maven-core), this is telling as well, but IMHO
> there is no need to deprecate this interface, as:
> * plugins who migrate from this ancient interface to Resolver will have much
> simpler job with maven 4 API (as it is much closer to Resolver than old Maven
> APIs)
> * this tackles only Plugins, while Maven itself is fine, as post Maven 4 the
> internals will be shut off, so warning Mojo authors is enough
> * still, we should look into core where and why is this type used for
> For Maven4 there are even more proposed changes:
> * deprecate localRepository used of {{ArtifactRepository}} type on
> following: {{{}MavenExecutionRequest{}}}, {{MavenSession and
> ProjectBuildingRequest}} as instance created for these are effectively not
> used (and are created "too early" and they carry repository system session
> anyway
--
This message was sent by Atlassian Jira
(v8.20.10#820010)