[
https://issues.apache.org/jira/browse/MNG-7566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17617829#comment-17617829
]
ASF GitHub Bot commented on MNG-7566:
-------------------------------------
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995920948
##########
maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginMavenPrerequisiteChecker.java:
##########
@@ -0,0 +1,74 @@
+package org.apache.maven.plugin.internal;
+
+/*
+ * 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.
+ */
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.plugin.MavenPluginPrerequisiteChecker;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.rtinfo.RuntimeInformation;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Named
+@Singleton
+public class MavenPluginMavenPrerequisiteChecker
+ implements MavenPluginPrerequisiteChecker
+{
+ private final Logger logger = LoggerFactory.getLogger( getClass() );
+ private final RuntimeInformation runtimeInformation;
+
+ @Inject
+ public MavenPluginMavenPrerequisiteChecker( RuntimeInformation
runtimeInformation )
+ {
+ super();
+ this.runtimeInformation = runtimeInformation;
+ }
+
+ @Override
+ public void accept( PluginDescriptor pluginDescriptor )
+ {
+ String requiredMavenVersion =
pluginDescriptor.getRequiredMavenVersion();
+ if ( StringUtils.isNotBlank( requiredMavenVersion ) )
+ {
+ boolean isRequirementMet = false;
+ try
+ {
+ isRequirementMet = runtimeInformation.isMavenVersion(
requiredMavenVersion );
+ }
+ catch ( RuntimeException e )
Review Comment:
this is the refactored old check. I haven't modified its implementation
apart from using another exception
(https://github.com/apache/maven/blob/c178b2fc1a4ff8ac852301b522fb2abdbdbf0cf6/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L321-L324)
> Allow a Maven plugin to require a Java version through its plugin descriptor
> ----------------------------------------------------------------------------
>
> Key: MNG-7566
> URL: https://issues.apache.org/jira/browse/MNG-7566
> Project: Maven
> Issue Type: Improvement
> Reporter: Konrad Windszus
> Assignee: Konrad Windszus
> Priority: Major
>
> Currently a Maven plugin can only require a minimum Maven version via pom's
> prerequisites (https://maven.apache.org/pom.html#Prerequisites). There is
> currently no means to require a minimum Java version.
> I would suggest to slightly expand the plugin descriptor to include a
> minimumJavaVersion element there as well and evaluate that before executing a
> plugin goal and emit a good error message. The default Java version could be
> determined by the target class file version.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)