You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/04/20 10:02:10 UTC

[maven-enforcer] branch stabilize created (now c84d3db)

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a change to branch stabilize
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git.


      at c84d3db  IT failures shouldn't be ignored

This branch includes the following new commits:

     new 4c28fbb  Move static methods to ArtifactUtils
     new f4f8c25  Merge branch 'master' of https://gitbox.apache.org/repos/asf/maven-enforcer
     new c84d3db  IT failures shouldn't be ignored

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-enforcer] 03/03: IT failures shouldn't be ignored

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch stabilize
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git

commit c84d3dbe38ae8756f85785f304f9971135457b76
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Apr 20 12:02:04 2019 +0200

    IT failures shouldn't be ignored
---
 maven-enforcer-plugin/pom.xml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/maven-enforcer-plugin/pom.xml b/maven-enforcer-plugin/pom.xml
index 0d2eda7..0842e22 100644
--- a/maven-enforcer-plugin/pom.xml
+++ b/maven-enforcer-plugin/pom.xml
@@ -151,6 +151,9 @@
   <profiles>
     <profile>
       <id>run-its</id>
+      <properties>
+        <maven.it.failure.ignore>false</maven.it.failure.ignore>
+      </properties>
       <build>
         <plugins>
           <plugin>
@@ -163,6 +166,7 @@
               <postBuildHookScript>verify</postBuildHookScript>
               <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
               <settingsFile>src/it/mrm/settings.xml</settingsFile>
+              <ignoreFailures>${maven.it.failure.ignore}</ignoreFailures>
               <goals>
                 <goal>validate</goal>
               </goals>


[maven-enforcer] 02/03: Merge branch 'master' of https://gitbox.apache.org/repos/asf/maven-enforcer

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch stabilize
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git

commit f4f8c2559e4af34d6db68f39b0d2e71e3b31e27f
Merge: 4c28fbb fad4dcc
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Apr 20 12:01:06 2019 +0200

    Merge branch 'master' of https://gitbox.apache.org/repos/asf/maven-enforcer

 .travis.yml                                        |  33 ++
 README.md                                          |   2 +-
 .../plugins/enforcer/AbstractBanDependencies.java  |   4 +-
 .../plugins/enforcer/AbstractRequireFiles.java     |   6 +-
 .../apache/maven/plugins/enforcer/AlwaysFail.java  |   2 +-
 .../apache/maven/plugins/enforcer/AlwaysPass.java  |   2 +-
 .../BanDuplicatePomDependencyVersions.java         |  14 +-
 .../enforcer/BanTransitiveDependencies.java        |   4 +-
 .../maven/plugins/enforcer/BannedPlugins.java      |   2 +-
 .../maven/plugins/enforcer/BannedRepositories.java |   6 +-
 .../plugins/enforcer/DependencyConvergence.java    |   9 +-
 .../plugins/enforcer/RequireActiveProfile.java     |   4 +-
 .../plugins/enforcer/RequireFilesDontExist.java    |   2 +-
 .../maven/plugins/enforcer/RequireFilesExist.java  |   2 +-
 .../plugins/enforcer/RequireNoRepositories.java    |   2 +-
 .../plugins/enforcer/RequirePluginVersions.java    | 418 ++++++++++++---------
 .../plugins/enforcer/RequireProfileIdsExist.java   |  27 +-
 .../plugins/enforcer/RequireReleaseVersion.java    |   2 +-
 .../plugins/enforcer/RequireSameVersions.java      |   7 +-
 .../plugins/enforcer/RequireSnapshotVersion.java   |   2 +-
 .../plugins/enforcer/RequireUpperBoundDeps.java    |   8 +-
 .../enforcer/TestRequirePluginVersions.java        |   1 +
 maven-enforcer-plugin/pom.xml                      |   2 +
 maven-enforcer-plugin/src/it/pom.xml               | 115 ------
 .../src/it/projects/MENFORCER-306/parent/pom.xml   | 103 +++++
 .../src/it/projects/MENFORCER-306/pom.xml          |  31 ++
 .../invoker.properties                             |  18 +
 .../pom.xml                                        |  65 ++++
 .../verify.groovy                                  |   9 +-
 .../require-plugin-versions-ci/verify.groovy       |   2 +-
 .../MENFORCER-322-module/pom.xml                   |  65 ++++
 .../invoker.properties                             |  27 ++
 .../pom.xml                                        |  63 ++++
 .../verify.groovy                                  |  43 +--
 .../apache/maven/plugins/enforcer/EnforceMojo.java |  26 +-
 maven-enforcer-plugin/src/site/apt/index.apt       |   4 +
 .../maven/plugins/enforcer/TestEnforceMojo.java    |  92 ++++-
 pom.xml                                            |   1 +
 38 files changed, 837 insertions(+), 388 deletions(-)



[maven-enforcer] 01/03: Move static methods to ArtifactUtils

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch stabilize
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git

commit 4c28fbb5d101ca8fdde06fa645e111597b60a1ca
Author: rfscholte <rf...@apache.org>
AuthorDate: Wed Nov 21 21:47:24 2018 +0100

    Move static methods to ArtifactUtils
---
 .../plugins/enforcer/AbstractBanDependencies.java  |  22 +---
 .../maven/plugins/enforcer/BannedDependencies.java |  76 +-----------
 .../plugins/enforcer/utils/ArtifactUtils.java      | 129 +++++++++++++++++++++
 3 files changed, 134 insertions(+), 93 deletions(-)

diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractBanDependencies.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractBanDependencies.java
index 5d3acb1..427aa97 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractBanDependencies.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractBanDependencies.java
@@ -23,6 +23,7 @@ import org.apache.maven.artifact.Artifact;
 import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
 import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
 import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.enforcer.utils.ArtifactUtils;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
 import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
@@ -121,7 +122,7 @@ public abstract class AbstractBanDependencies
             DependencyNode node = graphBuilder.buildDependencyGraph( project, null );
             if ( searchTransitive )
             {
-                dependencies = getAllDescendants( node );
+                dependencies = ArtifactUtils.getAllDescendants( node );
             }
             else if ( node.getChildren() != null )
             {
@@ -140,25 +141,6 @@ public abstract class AbstractBanDependencies
         return dependencies;
     }
 
-    private Set<Artifact> getAllDescendants( DependencyNode node )
-    {
-        Set<Artifact> children = null;
-        if ( node.getChildren() != null )
-        {
-            children = new HashSet<Artifact>();
-            for ( DependencyNode depNode : node.getChildren() )
-            {
-                children.add( depNode.getArtifact() );
-                Set<Artifact> subNodes = getAllDescendants( depNode );
-                if ( subNodes != null )
-                {
-                    children.addAll( subNodes );
-                }
-            }
-        }
-        return children;
-    }
-
     /**
      * Checks the set of dependencies against the list of excludes.
      *
diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java
index 5a41912..29785fa 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java
@@ -19,17 +19,13 @@ package org.apache.maven.plugins.enforcer;
  * under the License.
  */
 
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
 import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugins.enforcer.utils.ArtifactMatcher;
-import org.apache.maven.plugins.enforcer.utils.ArtifactMatcher.Pattern;
+import org.apache.maven.plugins.enforcer.utils.ArtifactUtils;
 
 /**
  * This rule checks that lists of dependencies are not included.
@@ -71,13 +67,13 @@ public class BannedDependencies
         throws EnforcerRuleException
     {
 
-        Set<Artifact> excluded = checkDependencies( theDependencies, excludes );
+        Set<Artifact> excluded = ArtifactUtils.checkDependencies( theDependencies, excludes );
 
         // anything specifically included should be removed
         // from the ban list.
         if ( excluded != null )
         {
-            Set<Artifact> included = checkDependencies( theDependencies, includes );
+            Set<Artifact> included = ArtifactUtils.checkDependencies( theDependencies, includes );
 
             if ( included != null )
             {
@@ -89,72 +85,6 @@ public class BannedDependencies
     }
 
     /**
-     * Checks the set of dependencies against the list of patterns.
-     * 
-     * @param thePatterns the patterns
-     * @param dependencies the dependencies
-     * @return a set containing artifacts matching one of the patterns or <code>null</code>
-     * @throws EnforcerRuleException the enforcer rule exception
-     */
-    private Set<Artifact> checkDependencies( Set<Artifact> dependencies, List<String> thePatterns )
-        throws EnforcerRuleException
-    {
-        Set<Artifact> foundMatches = null;
-
-        if ( thePatterns != null && thePatterns.size() > 0 )
-        {
-
-            for ( String pattern : thePatterns )
-            {
-                String[] subStrings = pattern.split( ":" );
-                subStrings = StringUtils.stripAll( subStrings );
-                String resultPattern = StringUtils.join( subStrings, ":" );
-
-                for ( Artifact artifact : dependencies )
-                {
-                    if ( compareDependency( resultPattern, artifact ) )
-                    {
-                        // only create if needed
-                        if ( foundMatches == null )
-                        {
-                            foundMatches = new HashSet<Artifact>();
-                        }
-                        foundMatches.add( artifact );
-                    }
-                }
-            }
-        }
-        return foundMatches;
-    }
-
-    /**
-     * Compares the given pattern against the given artifact. The pattern should follow the format
-     * <code>groupId:artifactId:version:type:scope:classifier</code>.
-     * 
-     * @param pattern The pattern to compare the artifact with.
-     * @param artifact the artifact
-     * @return <code>true</code> if the artifact matches one of the patterns
-     * @throws EnforcerRuleException the enforcer rule exception
-     */
-    protected boolean compareDependency( String pattern, Artifact artifact )
-        throws EnforcerRuleException
-    {
-
-        ArtifactMatcher.Pattern am = new Pattern( pattern );
-        boolean result;
-        try
-        {
-            result = am.match( artifact );
-        }
-        catch ( InvalidVersionSpecificationException e )
-        {
-            throw new EnforcerRuleException( "Invalid Version Range: ", e );
-        }
-
-        return result;
-    }
-
-    /**
      * Gets the excludes.
      * 
      * @return the excludes
diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactUtils.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactUtils.java
new file mode 100644
index 0000000..a839613
--- /dev/null
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/ArtifactUtils.java
@@ -0,0 +1,129 @@
+package org.apache.maven.plugins.enforcer.utils;
+
+/*
+ * 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.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.plugins.enforcer.utils.ArtifactMatcher.Pattern;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+
+/**
+ * 
+ * @author Robert Scholte
+ * @since 3.0.0
+ */
+public final class ArtifactUtils
+{
+    private ArtifactUtils()
+    {
+    }
+
+    public static Set<Artifact> getAllDescendants( DependencyNode node )
+    {
+        Set<Artifact> children = null;
+        if ( node.getChildren() != null )
+        {
+            children = new HashSet<Artifact>();
+            for ( DependencyNode depNode : node.getChildren() )
+            {
+                children.add( depNode.getArtifact() );
+                Set<Artifact> subNodes = getAllDescendants( depNode );
+                if ( subNodes != null )
+                {
+                    children.addAll( subNodes );
+                }
+            }
+        }
+        return children;
+    }
+
+    /**
+     * Checks the set of dependencies against the list of patterns.
+     * 
+     * @param thePatterns the patterns
+     * @param dependencies the dependencies
+     * @return a set containing artifacts matching one of the patterns or <code>null</code>
+     * @throws EnforcerRuleException the enforcer rule exception
+     */
+    public static Set<Artifact> checkDependencies( Set<Artifact> dependencies, List<String> thePatterns )
+        throws EnforcerRuleException
+    {
+        Set<Artifact> foundMatches = null;
+    
+        if ( thePatterns != null && thePatterns.size() > 0 )
+        {
+    
+            for ( String pattern : thePatterns )
+            {
+                String[] subStrings = pattern.split( ":" );
+                subStrings = StringUtils.stripAll( subStrings );
+                String resultPattern = StringUtils.join( subStrings, ":" );
+    
+                for ( Artifact artifact : dependencies )
+                {
+                    if ( compareDependency( resultPattern, artifact ) )
+                    {
+                        // only create if needed
+                        if ( foundMatches == null )
+                        {
+                            foundMatches = new HashSet<Artifact>();
+                        }
+                        foundMatches.add( artifact );
+                    }
+                }
+            }
+        }
+        return foundMatches;
+    }
+
+    /**
+     * Compares the given pattern against the given artifact. The pattern should follow the format
+     * <code>groupId:artifactId:version:type:scope:classifier</code>.
+     * 
+     * @param pattern The pattern to compare the artifact with.
+     * @param artifact the artifact
+     * @return <code>true</code> if the artifact matches one of the patterns
+     * @throws EnforcerRuleException the enforcer rule exception
+     */
+    private static boolean compareDependency( String pattern, Artifact artifact )
+        throws EnforcerRuleException
+    {
+    
+        ArtifactMatcher.Pattern am = new Pattern( pattern );
+        boolean result;
+        try
+        {
+            result = am.match( artifact );
+        }
+        catch ( InvalidVersionSpecificationException e )
+        {
+            throw new EnforcerRuleException( "Invalid Version Range: ", e );
+        }
+    
+        return result;
+    }
+
+}