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 2020/07/29 17:50:23 UTC

[GitHub] [maven-enforcer] TimSijstermans opened a new pull request #75: [MENFORCER-338] implement new rule RequireJavaVendor

TimSijstermans opened a new pull request #75:
URL: https://github.com/apache/maven-enforcer/pull/75


    - [ x ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
   This rule ensures that the system uses the given Java vendor 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [maven-enforcer] rfscholte commented on a change in pull request #75: [MENFORCER-338] implement new rule RequireJavaVendor

Posted by GitBox <gi...@apache.org>.
rfscholte commented on a change in pull request #75:
URL: https://github.com/apache/maven-enforcer/pull/75#discussion_r463514681



##########
File path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVendor.java
##########
@@ -0,0 +1,68 @@
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * 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 org.apache.commons.lang3.SystemUtils;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+
+/**
+ * This rule checks that the Java vendor is allowed.
+ *
+ * @author Tim Sijstermans
+ * @since 3.0.0
+ */
+public class RequireJavaVendor extends AbstractNonCacheableEnforcerRule
+{
+    private String name;
+
+    @Override
+    public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException
+    {
+        if ( !SystemUtils.JAVA_VENDOR.equals( name ) )
+        {
+            String message = getMessage();
+            String error = "Vendor " + SystemUtils.JAVA_VENDOR + " did not match required vendor " + name;
+            StringBuilder sb = new StringBuilder();
+            if ( message != null )
+            {
+                sb.append( message ).append( System.lineSeparator() );
+            }
+
+            sb.append( error );
+
+            throw new EnforcerRuleException( sb.toString() );
+        }
+    }
+
+    /**
+     * Specify the required name. Some examples are:
+     * <ul>
+     * <li><code>AdoptOpenJDK</code> enforces name AdoptOpenJDK </li>
+     * <li><code>Java.net</code> enforces name Amazon </li>

Review comment:
       Don't forget to add the rule to https://github.com/apache/maven-enforcer/blob/master/enforcer-rules/src/site/apt/index.apt




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [maven-enforcer] rfscholte commented on a change in pull request #75: [MENFORCER-338] implement new rule RequireJavaVendor

Posted by GitBox <gi...@apache.org>.
rfscholte commented on a change in pull request #75:
URL: https://github.com/apache/maven-enforcer/pull/75#discussion_r463513245



##########
File path: enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVendor.java
##########
@@ -0,0 +1,68 @@
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * 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 org.apache.commons.lang3.SystemUtils;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+
+/**
+ * This rule checks that the Java vendor is allowed.
+ *
+ * @author Tim Sijstermans
+ * @since 3.0.0
+ */
+public class RequireJavaVendor extends AbstractNonCacheableEnforcerRule
+{
+    private String name;
+
+    @Override
+    public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException
+    {
+        if ( !SystemUtils.JAVA_VENDOR.equals( name ) )
+        {
+            String message = getMessage();
+            String error = "Vendor " + SystemUtils.JAVA_VENDOR + " did not match required vendor " + name;
+            StringBuilder sb = new StringBuilder();
+            if ( message != null )
+            {
+                sb.append( message ).append( System.lineSeparator() );
+            }
+
+            sb.append( error );
+
+            throw new EnforcerRuleException( sb.toString() );
+        }
+    }
+
+    /**
+     * Specify the required name. Some examples are:
+     * <ul>
+     * <li><code>AdoptOpenJDK</code> enforces name AdoptOpenJDK </li>
+     * <li><code>Java.net</code> enforces name Amazon </li>

Review comment:
       Is this correct? I would suggest to say it uses an exact match of the System Property `java.vendor`, which you can also see with `mvn --version`




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [maven-enforcer] rfscholte commented on pull request #75: [MENFORCER-338] implement new rule RequireJavaVendor

Posted by GitBox <gi...@apache.org>.
rfscholte commented on pull request #75:
URL: https://github.com/apache/maven-enforcer/pull/75#issuecomment-667096342


   Merged with https://github.com/apache/maven-enforcer/commit/bdef97a2561ba2d2effd241649ad30a46c8133d4
   Thanks for the PR!


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [maven-enforcer] rfscholte closed pull request #75: [MENFORCER-338] implement new rule RequireJavaVendor

Posted by GitBox <gi...@apache.org>.
rfscholte closed pull request #75:
URL: https://github.com/apache/maven-enforcer/pull/75


   


----------------------------------------------------------------
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:
users@infra.apache.org