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/11/08 20:46:06 UTC

[GitHub] [maven-plugin-tools] slawekjaranowski commented on a diff in pull request #171: [MPLUGIN-425] Add required Java and Maven version to the generated

slawekjaranowski commented on code in PR #171:
URL: https://github.com/apache/maven-plugin-tools/pull/171#discussion_r1017094991


##########
maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java:
##########
@@ -102,6 +106,36 @@
 
     private static final GroupKey GROUP_KEY = new GroupKey( GroupKey.JAVA_GROUP, 100 );
 
+    /**
+     * 
+     * @see <a href="https://docs.oracle.com/javase/specs/jvms/se19/html/jvms-4.html#jvms-4.1">JVMS 4.1</a>
+     */
+    private static final Map<Integer, String> CLASS_VERSION_TO_JAVA_STRING;

Review Comment:
   We should add reference to this code from pom to remember that we need update together with asm 



##########
maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java:
##########
@@ -235,6 +239,44 @@
     @Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
     private ArtifactRepository local;
 
+    /**
+     * The required Java version to set in the plugin descriptor. This is evaluated by Maven 4 and ignored by earlier
+     * Maven versions. Can be either one of the following formats:
+     * 
+     * <ul>
+     * <li>One of the values as for <a href="https://maven.apache.org/pom.html#Activation">POM profile activation
+     * element {@code jdk}</a>, i.e. version ranges, version prefixes
+     * and negated version prefixes (starting with '!').</li>
+     * <li>{@code "auto"} to determine the minimum Java version from the binary class version being generated during
+     * compilation (determined by the extractor).</li>
+     * <li>{@code "none"} to not set a required Java version.</li>
+     * </ul>
+     * 
+     * @since 3.8.0
+     */
+    @Parameter( defaultValue = VALUE_AUTO )
+    String requiredJavaVersion;
+
+    /**
+     * The required Maven version to set in the plugin descriptor. This is evaluated by Maven 4 and ignored by earlier
+     * Maven versions. Can be either one of the following formats:
+     * 
+     * <ul>
+     * <li>A version range which specifies the supported Maven versions. It can either use the usual mathematical
+     * syntax like {@code "[2.0.10,2.1.0),[3.0,)"} or use a single version like {@code "2.2.1"}. The latter is a short
+     * form for {@code "[2.2.1,)"}, i.e. denotes the minimum version required.</li>
+     * <li>{@code "auto"} to determine the minimum Maven version from the POMs Maven prerequisite, or if not set the
+     * referenced Maven Plugin API version.</li>
+     * <li>{@code "none"} to not set a required Maven version.</li>

Review Comment:
   I would like to require always java version and maven version
   It will resolve MPLUGIN-418



##########
maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java:
##########
@@ -85,12 +87,18 @@ public Map<String, MojoAnnotatedClass> scan( MojoAnnotationsScannerRequest reque
             for ( Artifact dependency : request.getDependencies() )
             {
                 scan( mojoAnnotatedClasses, dependency.getFile(), request.getIncludePatterns(), dependency, true );
+                if ( request.getMavenApiVersion() == null
+                     && dependency.getFile().getName().contains( "maven-plugin-api" ) )
+                {
+                    request.setMavenApiVersion( getSpecificationVersionOfJar( dependency.getFile() ) );
+                }

Review Comment:
   Why not detect on Mojo level from dependencies?



-- 
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