[GitHub] [maven-enforcer] KroArtem commented on a change in pull request #86: [MENFORCER-376] Add excludes/includes functionality to RequireJavaVendor rule
KroArtem commented on a change in pull request #86: URL: https://github.com/apache/maven-enforcer/pull/86#discussion_r581165543 ## File path: enforcer-rules/src/site/apt/requireJavaVendor.apt.vm ## @@ -53,7 +56,13 @@ Require Java Vendor - AdoptOpenJDK + +Pivotal Review comment: These are the names I took from jdk.dev My current mvn -v returns the following: ``` Java version: 15.0.1, vendor: N/A, runtime: /usr/local/Cellar/openjdk/15.0.1/libexec/openjdk.jdk/Contents/Home ``` 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [maven-enforcer] KroArtem commented on a change in pull request #86: [MENFORCER-376] Add excludes/includes functionality to RequireJavaVendor rule
KroArtem commented on a change in pull request #86: URL: https://github.com/apache/maven-enforcer/pull/86#discussion_r565083783 ## File path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVendor.java ## @@ -31,40 +33,112 @@ */ public class RequireJavaVendor extends AbstractNonCacheableEnforcerRule { -private String name; +/** + * Specify the banned vendors. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * The rule will fail if vendor name matches any exclude, unless it also matches an + * include rule. + * + * Some examples are: + * + * AdoptOpenJDK prohibits vendor name AdoptOpenJDK + * Amazon prohibits vendor name Amazon + * + * + * @see #setExcludes(List) + * @see #getExcludes() + */ +private List excludes = null; + +/** + * Specify the allowed vendor names. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * Includes override the exclude rules. + * + * @see #setIncludes(List) + * @see #getIncludes() + */ +private List includes = null; @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { -if ( !SystemUtils.JAVA_VENDOR.equals( name ) ) +if ( excludes != null ) { -String message = getMessage(); -String error = "Vendor " + SystemUtils.JAVA_VENDOR + " did not match required vendor " + name; -StringBuilder sb = new StringBuilder(); -if ( message != null ) +if ( excludes.contains( SystemUtils.JAVA_VENDOR ) ) { -sb.append( message ).append( System.lineSeparator() ); +if ( includes != null ) +{ +if ( !includes.contains( SystemUtils.JAVA_VENDOR ) ) +{ +createException(); +} +return; +} +createException(); } - -sb.append( error ); - -throw new EnforcerRuleException( sb.toString() ); } } /** - * Specify the required name. Some examples are: - * Name should be an exact match of the System Property java.vendor, which you can also see with mvn --version + * Gets the excludes. * - * - * AdoptOpenJDK enforces vendor name AdoptOpenJDK - * Amazon enforces vendor name Amazon - * + * @return the excludes + */ +public List getExcludes() +{ +return this.excludes; +} + +/** + * Specify the banned vendors. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * The rule will fail if vendor name matches any exclude, unless it also matches an + * include rule. + * + * @see #getExcludes() + * @param theExcludes the excludes to set + */ +public void setExcludes( List theExcludes ) +{ +this.excludes = theExcludes; +} + +/** + * Gets the includes. * - * @param name the required name to set + * @return the includes */ -public final void setName( String name ) +public List getIncludes() { -this.name = name; +return this.includes; +} + +/** + * Specify the allowed vendor names. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * Includes override the exclude rules. + * * + * @see #setIncludes(List) + * @param theIncludes the includes to set + */ +public void setIncludes( List theIncludes ) +{ +this.includes = theIncludes; +} + +private void createException() throws EnforcerRuleException +{ +String message = getMessage(); +String error = "Vendor " + SystemUtils.JAVA_VENDOR + " is in a list of banned vendors: " + excludes; +StringBuilder sb = new StringBuilder(); +if ( message != null ) +{ +sb.append( message ).append( System.lineSeparator() ); Review comment: ok, I'll fix it today. Just understood that documentation (`requireJavaVendor.apt.vm`) has to be updated too. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [maven-enforcer] KroArtem commented on a change in pull request #86: [MENFORCER-376] Add excludes/includes functionality to RequireJavaVendor rule
KroArtem commented on a change in pull request #86: URL: https://github.com/apache/maven-enforcer/pull/86#discussion_r563658948 ## File path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVendor.java ## @@ -31,40 +33,112 @@ */ public class RequireJavaVendor extends AbstractNonCacheableEnforcerRule { -private String name; +/** + * Specify the banned vendors. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * The rule will fail if vendor name matches any exclude, unless it also matches an + * include rule. + * + * Some examples are: + * + * AdoptOpenJDK prohibits vendor name AdoptOpenJDK + * Amazon prohibits vendor name Amazon + * + * + * @see #setExcludes(List) + * @see #getExcludes() + */ +private List excludes = null; + +/** + * Specify the allowed vendor names. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * Includes override the exclude rules. + * + * @see #setIncludes(List) + * @see #getIncludes() + */ +private List includes = null; @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { -if ( !SystemUtils.JAVA_VENDOR.equals( name ) ) +if ( excludes != null ) { -String message = getMessage(); -String error = "Vendor " + SystemUtils.JAVA_VENDOR + " did not match required vendor " + name; -StringBuilder sb = new StringBuilder(); -if ( message != null ) +if ( excludes.contains( SystemUtils.JAVA_VENDOR ) ) { -sb.append( message ).append( System.lineSeparator() ); +if ( includes != null ) +{ +if ( !includes.contains( SystemUtils.JAVA_VENDOR ) ) +{ +createException(); +} +return; +} +createException(); } - -sb.append( error ); - -throw new EnforcerRuleException( sb.toString() ); } } /** - * Specify the required name. Some examples are: - * Name should be an exact match of the System Property java.vendor, which you can also see with mvn --version + * Gets the excludes. * - * - * AdoptOpenJDK enforces vendor name AdoptOpenJDK - * Amazon enforces vendor name Amazon - * + * @return the excludes + */ +public List getExcludes() +{ +return this.excludes; +} + +/** + * Specify the banned vendors. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * The rule will fail if vendor name matches any exclude, unless it also matches an + * include rule. + * + * @see #getExcludes() + * @param theExcludes the excludes to set + */ +public void setExcludes( List theExcludes ) +{ +this.excludes = theExcludes; +} + +/** + * Gets the includes. * - * @param name the required name to set + * @return the includes */ -public final void setName( String name ) +public List getIncludes() Review comment: What's up with backwards compatibility? This rule was not released in any version (M4 was not released), there is no information about this rule on site https://maven.apache.org/enforcer/enforcer-rules/index.html From my point of view, this was specifically done to prevent breaking backward compatibility in future. Here is your comment as an example https://issues.apache.org/jira/browse/MENFORCER-338?focusedCommentId=17169274=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17169274 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [maven-enforcer] KroArtem commented on a change in pull request #86: [MENFORCER-376] Add excludes/includes functionality to RequireJavaVendor rule
KroArtem commented on a change in pull request #86: URL: https://github.com/apache/maven-enforcer/pull/86#discussion_r563658948 ## File path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVendor.java ## @@ -31,40 +33,112 @@ */ public class RequireJavaVendor extends AbstractNonCacheableEnforcerRule { -private String name; +/** + * Specify the banned vendors. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * The rule will fail if vendor name matches any exclude, unless it also matches an + * include rule. + * + * Some examples are: + * + * AdoptOpenJDK prohibits vendor name AdoptOpenJDK + * Amazon prohibits vendor name Amazon + * + * + * @see #setExcludes(List) + * @see #getExcludes() + */ +private List excludes = null; + +/** + * Specify the allowed vendor names. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * Includes override the exclude rules. + * + * @see #setIncludes(List) + * @see #getIncludes() + */ +private List includes = null; @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { -if ( !SystemUtils.JAVA_VENDOR.equals( name ) ) +if ( excludes != null ) { -String message = getMessage(); -String error = "Vendor " + SystemUtils.JAVA_VENDOR + " did not match required vendor " + name; -StringBuilder sb = new StringBuilder(); -if ( message != null ) +if ( excludes.contains( SystemUtils.JAVA_VENDOR ) ) { -sb.append( message ).append( System.lineSeparator() ); +if ( includes != null ) +{ +if ( !includes.contains( SystemUtils.JAVA_VENDOR ) ) +{ +createException(); +} +return; +} +createException(); } - -sb.append( error ); - -throw new EnforcerRuleException( sb.toString() ); } } /** - * Specify the required name. Some examples are: - * Name should be an exact match of the System Property java.vendor, which you can also see with mvn --version + * Gets the excludes. * - * - * AdoptOpenJDK enforces vendor name AdoptOpenJDK - * Amazon enforces vendor name Amazon - * + * @return the excludes + */ +public List getExcludes() +{ +return this.excludes; +} + +/** + * Specify the banned vendors. This should be an exact match of the System Property + * java.vendor, which you can also see with mvn --version. + * The rule will fail if vendor name matches any exclude, unless it also matches an + * include rule. + * + * @see #getExcludes() + * @param theExcludes the excludes to set + */ +public void setExcludes( List theExcludes ) +{ +this.excludes = theExcludes; +} + +/** + * Gets the includes. * - * @param name the required name to set + * @return the includes */ -public final void setName( String name ) +public List getIncludes() Review comment: What's up with backwards compatibility? This rule was not released in any version (M4 was not released), there is no information about this rule on site https://maven.apache.org/enforcer/enforcer-rules/index.html From my point of view, this was specifically done to prevent breaking backward compatibility in future. Here is your comment as an example https://issues.apache.org/jira/browse/MENFORCER-338?focusedCommentId=17169274=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17169274 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org