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 2021/05/15 02:30:16 UTC

[GitHub] [maven-enforcer] marioja opened a new pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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


   MENFORCER-383  The rulesFile is better the the rules user property because it is
   possible to supply complete rules with arguments etc.
   
   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
    - [x ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MENFORCER) filed 
          for the change (usually before you start working on it).  Trivial changes like typos do not 
          require a JIRA issue.  Your pull request should address just this issue, without 
          pulling in other changes.
    - [x ] Each commit in the pull request should have a meaningful subject line and body.
    - [x ] Format the pull request title like `[MENFORCER-XXX] - Fixes bug in ApproximateQuantiles`,
          where you replace `MENFORCER-XXX` with the appropriate JIRA issue. Best practice
          is to use the JIRA issue title in the pull request title and in the first line of the 
          commit message.
    - [x ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [x ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will 
          be performed on your pull request automatically.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under 
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [ 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)
   
    - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   


-- 
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] marioja commented on pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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


   Added an IT test for the rulesFile user property.


-- 
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] marioja edited a comment on pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

Posted by GitBox <gi...@apache.org>.
marioja edited a comment on pull request #96:
URL: https://github.com/apache/maven-enforcer/pull/96#issuecomment-841679894


   I added second commit to handle recursion loop better.  On second executeMojo call I remove the rulesFilename from the configuration.  This has the benefit of allowing the use of rulesFilename along with rules configured in the  inheritance and merging them together if required in the future.  At this point it is neither implemented nor required.


-- 
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 #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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



##########
File path: maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
##########
@@ -150,6 +175,53 @@ public void execute()
             this.rules = createRulesFromCommandLineOptions();
         }
         
+        if ( rulesFilename != null && rulesFilename.length() > 0 )
+        {
+            Xpp3Dom configuration = null;
+            try
+            {
+                configuration = Xpp3DomBuilder.build( new FileReader( rulesFilename ) );
+            }
+            catch ( org.codehaus.plexus.util.xml.pull.XmlPullParserException | IOException e )
+            {
+                String apath = rulesFilename;
+                try
+                {
+                    apath = new File( rulesFilename ).getCanonicalPath();
+                }
+                catch ( IOException e1 )
+                {
+                }
+                throw new MojoExecutionException( "Unable to locate rules configuration xml file " + apath, e );
+            }
+            MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
+            
+            configuration = Xpp3DomUtils.mergeXpp3Dom( configuration,
+                toXpp3Dom( mojoDescriptor.getMojoConfiguration() ) );
+            Xpp3Dom[] cs = configuration.getChildren();
+            for ( int i = 0; i < cs.length; i++ )
+            {
+                Xpp3Dom c = cs[i];
+                if ( "rulesFilename".equals( c.getName() ) )
+                {
+                    configuration.removeChild( i ); // remove to avoid re-doing this if block
+                    break; // done exit
+                }
+            }
+            MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, configuration );
+            
+            try
+            {
+                pluginManager.executeMojo( session, mojoExecution );

Review comment:
       This is some kind of inception that doesn't make sense here. There is a better way to solve these kind of problems: maven-extensions.
   I've implemented MENFORCER-384, which makes commandlineRules absolete.




-- 
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 #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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


   I'm sorry that you've spend some time on this, but this was not the right approach (although I do understand your thinking).  This PR has been superseded with the implementation MENFORCER-384.


-- 
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 #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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


   


-- 
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] marioja commented on pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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






-- 
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] marioja edited a comment on pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

Posted by GitBox <gi...@apache.org>.
marioja edited a comment on pull request #96:
URL: https://github.com/apache/maven-enforcer/pull/96#issuecomment-841679894


   I added second commit to handle recursion loop better.  On second executeMojo call I remove the rulesFilename from the configuration.  This has the benefit of allowing the use of rulesFilename along with rules configured in the  inheritance and merging them together if required in the future.  At this point it is neither implemented nor required.


-- 
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] marioja commented on pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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


   ping?


-- 
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] marioja commented on pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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


   I added second commit to handle recursion loop better.  On second executeMojo call I remove the rulesFilename from the configuration.  This has the benefit of allowing the use of rulesFilename along with rules configured in the  inheritance and merging them together.


-- 
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] marioja commented on pull request #96: MENFORCER-383 add rulesFile user property to supply enforcer rules from cmd line

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


   This pr is ready for approval.  Can someone look into it.


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