You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/10/13 15:41:59 UTC

[GitHub] [maven] kwin opened a new pull request, #827: Allow a Maven plugin to require a Java version

kwin opened a new pull request, #827:
URL: https://github.com/apache/maven/pull/827

   Currently just a draft around https://issues.apache.org/jira/browse/MPLUGIN-424 (which needs to be moved to MNG JIRA)


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995930768


##########
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:
   Ok, fixed in https://github.com/apache/maven/pull/827/commits/04cffe8f70ae94111e84ed44eaa810aec6a69541.



##########
maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java:
##########
@@ -303,25 +308,36 @@ public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<Remote
         return mojoDescriptor;
     }
 
-    public void checkRequiredMavenVersion( PluginDescriptor pluginDescriptor )
+    
+    @Override
+    public void checkPrerequisites( PluginDescriptor pluginDescriptor )
         throws PluginIncompatibleException
     {
-        String requiredMavenVersion = pluginDescriptor.getRequiredMavenVersion();
-        if ( StringUtils.isNotBlank( requiredMavenVersion ) )
-        {
-            try
-            {
-                if ( !runtimeInformation.isMavenVersion( requiredMavenVersion ) )
-                {
-                    throw new PluginIncompatibleException( pluginDescriptor.getPlugin(),
-                                                           "The plugin " + pluginDescriptor.getId()
-                                                               + " requires Maven version " + requiredMavenVersion );
-                }
-            }
-            catch ( RuntimeException e )
-            {
-                logger.warn( "Could not verify plugin's Maven prerequisite: " + e.getMessage() );
-            }
+        List<IllegalStateException> prerequisiteExceptions = new ArrayList<>();
+        prerequisiteCheckers.forEach( c -> 
+        {
+            try 
+            { 
+                c.accept( pluginDescriptor );
+            } 
+            catch ( IllegalStateException e )
+            {
+                prerequisiteExceptions.add( e );
+            }
+        } );
+        // aggregate all exceptions
+        if ( !prerequisiteExceptions.isEmpty() )
+        {
+            String messages = prerequisiteExceptions.stream()
+                            .map( IllegalStateException::getMessage )
+                            .collect( Collectors.joining( ", " ) );
+            PluginIncompatibleException pie  = new PluginIncompatibleException( pluginDescriptor.getPlugin(),
+                                                   "The plugin " + pluginDescriptor.getId()
+                                                       + " has unmet requirements: " 

Review Comment:
   done in https://github.com/apache/maven/pull/827/commits/04cffe8f70ae94111e84ed44eaa810aec6a69541.



##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{
+    /**
+     * 
+     * @param pluginDescriptor
+     * @throws IllegalStateException in case the checked prerequisite is not met

Review Comment:
   done in https://github.com/apache/maven/pull/827/commits/04cffe8f70ae94111e84ed44eaa810aec6a69541.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on pull request #827: Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on PR #827:
URL: https://github.com/apache/maven/pull/827#issuecomment-1277966331

   @slawekjaranowski Thanks for the proposal, sounds good, but I am not sure when to call the validator. From both places where `MavenPluginManager#checkRequiredMavenVersion` is currently called? That may IMHO be too often and it seems that the `DefaultPluginVersionResolver#isCompatible(...)` is just silently ignoring incompatible versions. Also version incompatibility for me is semantically different from an invalid plugin descriptor. Therefore I am not sure about the naming `PluginDescriptorValidator`. The other validators primarily check for valid XML, which is different from compatibility.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995918956


##########
maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java:
##########
@@ -0,0 +1,52 @@
+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.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.model.profile.activation.JdkVersionProfileActivator;
+import org.apache.maven.plugin.MavenPluginPrerequisiteChecker;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.codehaus.plexus.util.StringUtils;
+
+@Named
+@Singleton
+public class MavenPluginJavaPrerequisiteChecker
+    implements MavenPluginPrerequisiteChecker
+{
+
+    @Override
+    public void accept( PluginDescriptor pluginDescriptor )
+    {
+        String requiredJavaVersion = pluginDescriptor.getRequiredJavaVersion();
+        if ( StringUtils.isNotBlank( requiredJavaVersion ) )
+        {
+            String currentJavaVersion = System.getProperty( "java.version" );

Review Comment:
   yes, it uses even the same code.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995916781


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{

Review Comment:
   Why? This is the interface declaration not a method declaration.
   
   > If you do not specify that the interface is public, then your interface is accessible only to classes defined in the same package as the interface.
   
   (https://docs.oracle.com/javase/tutorial/java/IandI/interfaceDef.html)



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995924592


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{

Review Comment:
   My misconception. It applies only to methods:
   
        All abstract, default, and static methods in an interface are implicitly public, so you can omit the public modifier.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on PR #827:
URL: https://github.com/apache/maven/pull/827#issuecomment-1279137428

   > Stupid question: Does not prevent Invalid class version exception? I mean when the classes are already loaded then this is too late, no?
   
   Which classes are loaded already before prerequisites are checked? IMHO this happens before the plugin classloader is even created. Not sure about extensions which are part of plugins, though.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995941308


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>

Review Comment:
   done in https://github.com/apache/maven/pull/827/commits/04cffe8f70ae94111e84ed44eaa810aec6a69541



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r994821661


##########
maven-plugin-api/src/main/mdo/plugin.mdo:
##########
@@ -91,6 +91,12 @@ under the License.
           <type>boolean</type>
           <defaultValue>true</defaultValue>
         </field>
+        <field>
+          <name>requiredJavaVersion</name>
+          <version>1.1.0</version>
+          <description>A version range which specifies the supported Java versions.</description>

Review Comment:
   This supports the same syntax as JDK profile activation (https://maven.apache.org/guides/introduction/introduction-to-profiles.html#details-on-profile-activation)



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r997859144


##########
maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java:
##########
@@ -164,7 +167,8 @@ public DefaultMavenPluginManager(
             PluginVersionResolver pluginVersionResolver,
             PluginArtifactsCache pluginArtifactsCache,
             MavenPluginValidator pluginValidator,
-            List<MavenPluginConfigurationValidator> configurationValidators )
+            List<MavenPluginConfigurationValidator> configurationValidators,
+            List<MavenPluginPrerequisitesChecker> prerequisiteCheckers )

Review Comment:
   `prerequisitesCheckers`



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995917735


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{
+    /**
+     * 
+     * @param pluginDescriptor
+     * @throws IllegalStateException in case the checked prerequisite is not met
+     */
+    void accept( PluginDescriptor pluginDescriptor ) throws IllegalStateException;

Review Comment:
   right, but I would still list it explicitly here for clarity reasons that implementations are expected to throw this.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995925177


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{
+    /**
+     * 
+     * @param pluginDescriptor
+     * @throws IllegalStateException in case the checked prerequisite is not met
+     */
+    void accept( PluginDescriptor pluginDescriptor ) throws IllegalStateException;

Review Comment:
   Not necessary, we have the Javadoc. See Effective Java by J. Bloch.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #827:
URL: https://github.com/apache/maven/pull/827#issuecomment-1279206257

   > > Stupid question: Does not prevent Invalid class version exception? I mean when the classes are already loaded then this is too late, no?
   > 
   > Which classes are loaded already before prerequisites are checked? IMHO this happens before the plugin classloader is even created. Not sure about extensions which are part of plugins, though.
   
   This is exactly what I expected to hear!


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995798745


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>

Review Comment:
   `Prerequisites` since it could check multiple ones, no?



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] slawekjaranowski commented on pull request #827: Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on PR #827:
URL: https://github.com/apache/maven/pull/827#issuecomment-1277912731

   Proposition  
    - create component component like `PluginDescriptorValidator` 
    - create two implementation one for Maven version and second new for Java varsion
    - inject list of component  in DefaultPluginVersionResolver
    - remove old method `MavenPluginManager#checkRequiredMavenVersion`
    
   The method `MavenPluginManager#checkRequiredMavenVersion` is also called from `MojoExecutor` - maybe not needed


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
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)



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin merged pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin merged PR #827:
URL: https://github.com/apache/maven/pull/827


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995798745


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>

Review Comment:
   `Prerequisites` sind it could check multiple ones, no?



##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{

Review Comment:
   `public` is redundant



##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{
+    /**
+     * 
+     * @param pluginDescriptor
+     * @throws IllegalStateException in case the checked prerequisite is not met

Review Comment:
   prerequisites



##########
maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java:
##########
@@ -303,25 +308,36 @@ public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<Remote
         return mojoDescriptor;
     }
 
-    public void checkRequiredMavenVersion( PluginDescriptor pluginDescriptor )
+    
+    @Override
+    public void checkPrerequisites( PluginDescriptor pluginDescriptor )
         throws PluginIncompatibleException
     {
-        String requiredMavenVersion = pluginDescriptor.getRequiredMavenVersion();
-        if ( StringUtils.isNotBlank( requiredMavenVersion ) )
-        {
-            try
-            {
-                if ( !runtimeInformation.isMavenVersion( requiredMavenVersion ) )
-                {
-                    throw new PluginIncompatibleException( pluginDescriptor.getPlugin(),
-                                                           "The plugin " + pluginDescriptor.getId()
-                                                               + " requires Maven version " + requiredMavenVersion );
-                }
-            }
-            catch ( RuntimeException e )
-            {
-                logger.warn( "Could not verify plugin's Maven prerequisite: " + e.getMessage() );
-            }
+        List<IllegalStateException> prerequisiteExceptions = new ArrayList<>();
+        prerequisiteCheckers.forEach( c -> 
+        {
+            try 
+            { 
+                c.accept( pluginDescriptor );
+            } 
+            catch ( IllegalStateException e )
+            {
+                prerequisiteExceptions.add( e );
+            }
+        } );
+        // aggregate all exceptions
+        if ( !prerequisiteExceptions.isEmpty() )
+        {
+            String messages = prerequisiteExceptions.stream()
+                            .map( IllegalStateException::getMessage )
+                            .collect( Collectors.joining( ", " ) );
+            PluginIncompatibleException pie  = new PluginIncompatibleException( pluginDescriptor.getPlugin(),
+                                                   "The plugin " + pluginDescriptor.getId()
+                                                       + " has unmet requirements: " 
+                                                       + messages, prerequisiteExceptions.get( 0 ) );
+            // the first exception is added as cause, all other ones as suppressed exceptions
+            prerequisiteExceptions.stream().skip( 1 ).forEach( pie::addSuppressed );
+            throw pie;

Review Comment:
   lambda pr0n!



##########
maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java:
##########
@@ -0,0 +1,52 @@
+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.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.model.profile.activation.JdkVersionProfileActivator;
+import org.apache.maven.plugin.MavenPluginPrerequisiteChecker;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.codehaus.plexus.util.StringUtils;
+
+@Named
+@Singleton
+public class MavenPluginJavaPrerequisiteChecker
+    implements MavenPluginPrerequisiteChecker
+{
+
+    @Override
+    public void accept( PluginDescriptor pluginDescriptor )
+    {
+        String requiredJavaVersion = pluginDescriptor.getRequiredJavaVersion();
+        if ( StringUtils.isNotBlank( requiredJavaVersion ) )
+        {
+            String currentJavaVersion = System.getProperty( "java.version" );

Review Comment:
   Does it use the same approach as the JDK profile activation?



##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{
+    /**
+     * 
+     * @param pluginDescriptor
+     * @throws IllegalStateException in case the checked prerequisite is not met
+     */
+    void accept( PluginDescriptor pluginDescriptor ) throws IllegalStateException;

Review Comment:
   throws is redundant for runtime exceptions



##########
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:
   How? The API spec says:
   
       @throws IllegalArgumentException If the specified version range is {@code null}, empty or otherwise not a valid version specification.



##########
maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java:
##########
@@ -303,25 +308,36 @@ public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<Remote
         return mojoDescriptor;
     }
 
-    public void checkRequiredMavenVersion( PluginDescriptor pluginDescriptor )
+    
+    @Override
+    public void checkPrerequisites( PluginDescriptor pluginDescriptor )
         throws PluginIncompatibleException
     {
-        String requiredMavenVersion = pluginDescriptor.getRequiredMavenVersion();
-        if ( StringUtils.isNotBlank( requiredMavenVersion ) )
-        {
-            try
-            {
-                if ( !runtimeInformation.isMavenVersion( requiredMavenVersion ) )
-                {
-                    throw new PluginIncompatibleException( pluginDescriptor.getPlugin(),
-                                                           "The plugin " + pluginDescriptor.getId()
-                                                               + " requires Maven version " + requiredMavenVersion );
-                }
-            }
-            catch ( RuntimeException e )
-            {
-                logger.warn( "Could not verify plugin's Maven prerequisite: " + e.getMessage() );
-            }
+        List<IllegalStateException> prerequisiteExceptions = new ArrayList<>();
+        prerequisiteCheckers.forEach( c -> 
+        {
+            try 
+            { 
+                c.accept( pluginDescriptor );
+            } 
+            catch ( IllegalStateException e )
+            {
+                prerequisiteExceptions.add( e );
+            }
+        } );
+        // aggregate all exceptions
+        if ( !prerequisiteExceptions.isEmpty() )
+        {
+            String messages = prerequisiteExceptions.stream()
+                            .map( IllegalStateException::getMessage )
+                            .collect( Collectors.joining( ", " ) );
+            PluginIncompatibleException pie  = new PluginIncompatibleException( pluginDescriptor.getPlugin(),
+                                                   "The plugin " + pluginDescriptor.getId()
+                                                       + " has unmet requirements: " 

Review Comment:
   requirements >= prerequisites?



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995925661


##########
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:
   Personally, I'd touch it to make it proper this time.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] kwin commented on a diff in pull request #827: [MNG-7566] Allow a Maven plugin to require a Java version

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #827:
URL: https://github.com/apache/maven/pull/827#discussion_r995940629


##########
maven-core/src/main/java/org/apache/maven/plugin/MavenPluginPrerequisiteChecker.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.function.Consumer;
+
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+
+/**
+ * Service responsible for checking if plugin's prerequisites are met.
+ */
+@FunctionalInterface
+public interface MavenPluginPrerequisiteChecker extends Consumer<PluginDescriptor>
+{
+    /**
+     * 
+     * @param pluginDescriptor
+     * @throws IllegalStateException in case the checked prerequisite is not met
+     */
+    void accept( PluginDescriptor pluginDescriptor ) throws IllegalStateException;

Review Comment:
   removed in https://github.com/apache/maven/pull/827/commits/2b2062338a03246f6308c25429b160a02d1d0f52.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org