You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2018/01/06 20:28:01 UTC
[maven-enforcer] branch master updated (655a24e -> ad0a843)
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git.
from 655a24e [MENFORCER-221] Removed deprecated marked constructor from EnforcerExpressionEvaluator
add 5311c57 [MENFORCER-281] RequirePluginVersions broken with "CI Friendly versions" o added IT to show the issue.
new ad0a843 [MENFORCER-281] RequirePluginVersions broken with "CI Friendly versions" o Followup o Added selector condition to limit execution to Maven 3.5.0+ for the invoker integration test. o Replaced EnforcerRuleUtils.getModelsRecursively method with session.getProjectDependencyGraph().getSortedProjects() o Removed the testGetAllPlugins() and all related tests from TestEnforcerRuleUtils cause it only tests the getModelsRecursively method. Left only a [...]
The 1 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.
Summary of changes:
.../plugins/enforcer/RequirePluginVersions.java | 18 +-
.../plugins/enforcer/utils/EnforcerRuleUtils.java | 211 -----------------
.../enforcer/TestRequirePluginVersions.java | 38 ---
.../plugins/enforcer/TestRequireReleaseDeps.java | 16 +-
.../enforcer/TestRequireReleaseVersion.java | 10 +-
.../enforcer/TestRequireSnapshotVersion.java | 14 +-
.../EnforcerRuleUtilsHelper.java} | 58 ++---
.../enforcer/utils/TestEnforcerRuleUtils.java | 263 ---------------------
.../invoker.properties | 3 +-
.../menforcer281-module}/pom.xml | 9 +-
.../require-plugin-versions-mm-ci-friendly/pom.xml | 115 +++++++++
11 files changed, 168 insertions(+), 587 deletions(-)
copy enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/{TestMavenVersion.java => utils/EnforcerRuleUtilsHelper.java} (55%)
delete mode 100644 enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestEnforcerRuleUtils.java
copy maven-enforcer-plugin/src/it/projects/{require-plugin-versions-ci => require-plugin-versions-mm-ci-friendly}/invoker.properties (94%)
copy maven-enforcer-plugin/src/it/projects/{require-plugin-versions-ci/child => require-plugin-versions-mm-ci-friendly/menforcer281-module}/pom.xml (86%)
create mode 100644 maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/pom.xml
--
To stop receiving notification emails like this one, please contact
['"commits@maven.apache.org" <co...@maven.apache.org>'].
[maven-enforcer] 01/01: [MENFORCER-281] RequirePluginVersions
broken with "CI Friendly versions" o Followup o Added selector condition to
limit execution to Maven 3.5.0+ for the invoker integration test. o
Replaced EnforcerRuleUtils.getModelsRecursively method with
session.getProjectDependencyGraph().getSortedProjects() o Removed the
testGetAllPlugins() and all related tests from TestEnforcerRuleUtils cause
it only tests the getModelsRecursively method. Left only a static method
[...]
Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git
commit ad0a84368f97a335a9455f04ec04bfbbb10ac49e
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sat Jan 6 20:09:35 2018 +0100
[MENFORCER-281] RequirePluginVersions broken with "CI Friendly versions"
o Followup
o Added selector condition to limit execution to Maven 3.5.0+
for the invoker integration test.
o Replaced EnforcerRuleUtils.getModelsRecursively
method with session.getProjectDependencyGraph().getSortedProjects()
o Removed the testGetAllPlugins() and all related tests
from TestEnforcerRuleUtils cause it only tests the
getModelsRecursively method. Left only a static method
and renamed to EnforcerRuleUtilsHelper cause it's
used in some Tests.
---
.../plugins/enforcer/RequirePluginVersions.java | 18 +-
.../plugins/enforcer/utils/EnforcerRuleUtils.java | 211 -----------------
.../enforcer/TestRequirePluginVersions.java | 38 ---
.../plugins/enforcer/TestRequireReleaseDeps.java | 16 +-
.../enforcer/TestRequireReleaseVersion.java | 10 +-
.../enforcer/TestRequireSnapshotVersion.java | 14 +-
.../enforcer/utils/EnforcerRuleUtilsHelper.java | 62 +++++
.../enforcer/utils/TestEnforcerRuleUtils.java | 263 ---------------------
.../invoker.properties | 1 +
9 files changed, 89 insertions(+), 544 deletions(-)
diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
index 81ebb5e..9e840da 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
@@ -19,7 +19,6 @@ package org.apache.maven.plugins.enforcer;
* under the License.
*/
-import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -1046,19 +1045,14 @@ public class RequirePluginVersions
List<PluginWrapper> plugins = new ArrayList<PluginWrapper>();
// get all the pom models
- String pomName = null;
- try
- {
- pomName = project.getFile().getName();
- }
- catch ( Exception e )
+ List<Model> models = new ArrayList<Model>();
+
+ List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects();
+ for ( MavenProject mavenProject : sortedProjects )
{
- pomName = "pom.xml";
+ models.add( mavenProject.getOriginalModel() );
}
- List<Model> models =
- utils.getModelsRecursively( project.getGroupId(), project.getArtifactId(), project.getVersion(),
- new File( project.getBasedir(), pomName ) );
-
+
// now find all the plugin entries, either in
// build.plugins or build.pluginManagement.plugins, profiles.plugins and reporting
for ( Model model : models )
diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
index c5f4bdd..c122e10 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java
@@ -19,31 +19,18 @@ package org.apache.maven.plugins.enforcer.utils;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
import java.util.List;
-import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/**
* The Class EnforcerRuleUtils.
@@ -126,204 +113,6 @@ public class EnforcerRuleUtils
}
}
- /**
- * Gets the pom model for this file.
- *
- * @param pom the pom
- * @return the model
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws XmlPullParserException the xml pull parser exception
- */
- private Model readModel( File pom )
- throws IOException, XmlPullParserException
- {
- Reader reader = ReaderFactory.newXmlReader( pom );
- MavenXpp3Reader xpp3 = new MavenXpp3Reader();
- Model model = null;
- try
- {
- model = xpp3.read( reader );
- }
- finally
- {
- reader.close();
- reader = null;
- }
- return model;
- }
-
- /**
- * This method gets the model for the defined artifact. Looks first in the filesystem, then tries to get it from the
- * repo.
- *
- * @param groupId the group id
- * @param artifactId the artifact id
- * @param version the version
- * @param pom the pom
- * @return the pom model
- * @throws ArtifactResolutionException the artifact resolution exception
- * @throws ArtifactNotFoundException the artifact not found exception
- * @throws XmlPullParserException the xml pull parser exception
- * @throws IOException Signals that an I/O exception has occurred.
- */
- private Model getPomModel( String groupId, String artifactId, String version, File pom )
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- Model model = null;
-
- // do we want to look in the reactor like the
- // project builder? Would require @aggregator goal
- // which causes problems in maven core right now
- // because we also need dependency resolution in
- // other
- // rules. (MNG-2277)
-
- // look in the location specified by pom first.
- boolean found = false;
- try
- {
- model = readModel( pom );
-
- // i found a model, lets make sure it's the one
- // I want
- found = checkIfModelMatches( groupId, artifactId, version, model );
- }
- catch ( IOException e )
- {
- // nothing here, but lets look in the repo
- // before giving up.
- }
- catch ( XmlPullParserException e )
- {
- // nothing here, but lets look in the repo
- // before giving up.
- }
-
- // i didn't find it in the local file system, go
- // look in the repo
- if ( !found )
- {
- Artifact pomArtifact = factory.createArtifact( groupId, artifactId, version, null, "pom" );
- resolver.resolve( pomArtifact, remoteRepositories, local );
- model = readModel( pomArtifact.getFile() );
- }
-
- return model;
- }
-
- /**
- * This method loops through all the parents, getting each pom model and then its parent.
- *
- * @param groupId the group id
- * @param artifactId the artifact id
- * @param version the version
- * @param pom the pom
- * @return the models recursively
- * @throws ArtifactResolutionException the artifact resolution exception
- * @throws ArtifactNotFoundException the artifact not found exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws XmlPullParserException the xml pull parser exception
- */
- public List<Model> getModelsRecursively( String groupId, String artifactId, String version, File pom )
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- List<Model> models = null;
- Model model = getPomModel( groupId, artifactId, version, pom );
-
- Parent parent = model.getParent();
-
- // recurse into the parent
- if ( parent != null )
- {
- // get the relative path
- String relativePath = parent.getRelativePath();
- if ( StringUtils.isEmpty( relativePath ) )
- {
- relativePath = "../pom.xml";
- }
- // calculate the recursive path
- File parentPom = new File( pom.getParent(), relativePath );
-
- // if relative path is a directory, append pom.xml
- if ( parentPom.isDirectory() )
- {
- parentPom = new File( parentPom, "pom.xml" );
- }
-
- //@formatter:off
- models = getModelsRecursively( parent.getGroupId(), parent.getArtifactId(),
- parent.getVersion(), parentPom );
- //@formatter:on
- }
- else
- {
- // only create it here since I'm not at the top
- models = new ArrayList<Model>();
- }
- models.add( model );
-
- return models;
- }
-
- /**
- * Make sure the model is the one I'm expecting.
- *
- * @param groupId the group id
- * @param artifactId the artifact id
- * @param version the version
- * @param model Model being checked.
- * @return true, if check if model matches
- */
- protected boolean checkIfModelMatches( String groupId, String artifactId, String version, Model model )
- {
- // try these first.
- String modelGroup = model.getGroupId();
- String modelArtifactId = model.getArtifactId();
- String modelVersion = model.getVersion();
-
- try
- {
- if ( StringUtils.isEmpty( modelGroup ) )
- {
- modelGroup = model.getParent().getGroupId();
- }
- else
- {
- // MENFORCER-30, handle cases where the value is a property like ${project.parent.groupId}
- modelGroup = (String) helper.evaluate( modelGroup );
- }
-
- if ( StringUtils.isEmpty( modelVersion ) )
- {
- modelVersion = model.getParent().getVersion();
- }
- else
- {
- // MENFORCER-30, handle cases where the value is a property like ${project.parent.version}
- modelVersion = (String) helper.evaluate( modelVersion );
- }
-
- // Is this only required for Maven2?
- modelArtifactId = (String) helper.evaluate( modelArtifactId );
- }
- catch ( NullPointerException e )
- {
- // this is probably bad. I don't have a valid
- // group or version and I can't find a
- // parent????
- // lets see if it's what we're looking for
- // anyway.
- }
- catch ( ExpressionEvaluationException e )
- {
- // as above
- }
- // CHECKSTYLE_OFF: LineLength
- return ( StringUtils.equals( groupId, modelGroup ) && StringUtils.equals( version, modelVersion ) && StringUtils.equals( artifactId,
- modelArtifactId ) );
- // CHECKSTYLE_ON: LineLength
- }
-
private void resolve( Plugin plugin )
{
try
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java
index bbd4e8b..422967d 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java
@@ -19,24 +19,17 @@ package org.apache.maven.plugins.enforcer;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtils;
import org.apache.maven.plugins.enforcer.utils.PluginWrapper;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/**
* The Class TestRequirePluginVersions.
@@ -190,37 +183,6 @@ public class TestRequirePluginVersions
}
/**
- * Test get all plugins.
- *
- * @throws ArtifactResolutionException the artifact resolution exception
- * @throws ArtifactNotFoundException the artifact not found exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws XmlPullParserException the xml pull parser exception
- */
- public void testGetAllPlugins()
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- RequirePluginVersions rule = new RequirePluginVersions();
- String path = "target/test-classes/requirePluginVersions/getPomRecursively/b/c";
-
- StringUtils.replace( path, "/", File.separator );
-
- File projectDir = new File( getBasedir(), path );
-
- MockProject project = new MockProject();
- project.setArtifactId( "c" );
- project.setGroupId( "group" );
- project.setVersion( "1.0" );
- project.setBaseDir( projectDir );
-
- rule.setUtils( new EnforcerRuleUtils( EnforcerTestUtils.getHelper( project ) ) );
- List<PluginWrapper> plugins = rule.getAllPluginEntries( project );
-
- // there should be 3
- assertEquals( 3, plugins.size() );
- }
-
- /**
* Test get additional plugins null.
*
* @throws MojoExecutionException the mojo execution exception
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseDeps.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseDeps.java
index efe023e..858e60f 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseDeps.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseDeps.java
@@ -27,7 +27,7 @@ import junit.framework.TestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
-import org.apache.maven.plugins.enforcer.utils.TestEnforcerRuleUtils;
+import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtilsHelper;
import org.apache.maven.project.MavenProject;
/**
@@ -56,25 +56,25 @@ public class TestRequireReleaseDeps
RequireReleaseDeps rule = newRequireReleaseDeps();
rule.setSearchTransitive( false );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
rule.setSearchTransitive( true );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
// test onlyWhenRelease in each case
project.setArtifact( factory.getSnapshotArtifact() );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
rule.setOnlyWhenRelease( true );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
project.setArtifact( factory.getReleaseArtifact() );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
MockProject parent = new MockProject();
parent.setArtifact( factory.getSnapshotArtifact() );
@@ -84,10 +84,10 @@ public class TestRequireReleaseDeps
helper = EnforcerTestUtils.getHelper(project);
rule.setFailWhenParentIsSnapshot( true );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
rule.setFailWhenParentIsSnapshot( false );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
}
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseVersion.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseVersion.java
index 0a65bba..286008e 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseVersion.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseVersion.java
@@ -26,7 +26,7 @@ import junit.framework.TestCase;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
-import org.apache.maven.plugins.enforcer.utils.TestEnforcerRuleUtils;
+import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtilsHelper;
/**
* The Class TestRequireReleaseVersion.
@@ -53,11 +53,11 @@ public class TestRequireReleaseVersion
EnforcerRule rule = new RequireReleaseVersion();
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
project.setArtifact( factory.getSnapshotArtifact() );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
project.setArtifact( factory.getReleaseArtifact() );
@@ -67,10 +67,10 @@ public class TestRequireReleaseVersion
helper = EnforcerTestUtils.getHelper(project);
( (RequireReleaseVersion) rule ).setFailWhenParentIsSnapshot( true );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
( (RequireReleaseVersion) rule ).setFailWhenParentIsSnapshot( false );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
}
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java
index 4c1c60e..2fd08a9 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireSnapshotVersion.java
@@ -21,7 +21,7 @@ package org.apache.maven.plugins.enforcer;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
-import org.apache.maven.plugins.enforcer.utils.TestEnforcerRuleUtils;
+import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtilsHelper;
import org.apache.maven.project.MavenProject;
import org.junit.Before;
import org.junit.Test;
@@ -56,10 +56,10 @@ public class TestRequireSnapshotVersion
throws IOException
{
project.setArtifact( factory.getReleaseArtifact() );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
project.setArtifact( factory.getSnapshotArtifact() );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
}
@Test
@@ -72,12 +72,12 @@ public class TestRequireSnapshotVersion
MockProject parent = new MockProject();
parent.setArtifact( factory.getReleaseArtifact() );
project.setParent( parent );
- TestEnforcerRuleUtils.execute( rule, helper, true );
+ EnforcerRuleUtilsHelper.execute( rule, helper, true );
parent = new MockProject();
parent.setArtifact( factory.getSnapshotArtifact() );
project.setParent( parent );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
}
@Test
@@ -90,12 +90,12 @@ public class TestRequireSnapshotVersion
MockProject parent = new MockProject();
parent.setArtifact( factory.getReleaseArtifact() );
project.setParent( parent );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
parent = new MockProject();
parent.setArtifact( factory.getSnapshotArtifact() );
project.setParent( parent );
- TestEnforcerRuleUtils.execute( rule, helper, false );
+ EnforcerRuleUtilsHelper.execute( rule, helper, false );
}
}
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
new file mode 100644
index 0000000..37d98bc
--- /dev/null
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtilsHelper.java
@@ -0,0 +1,62 @@
+package org.apache.maven.plugins.enforcer.utils;
+
+import static org.junit.Assert.fail;
+
+/*
+ * 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.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+
+/**
+ * The Class TestEnforcerRuleUtils.
+ *
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ */
+public class EnforcerRuleUtilsHelper
+{
+
+ /**
+ * Simpler wrapper to execute and deal with the expected result.
+ *
+ * @param rule the rule
+ * @param helper the helper
+ * @param shouldFail the should fail
+ */
+ public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail )
+ {
+ try
+ {
+ rule.execute( helper );
+ if ( shouldFail )
+ {
+ fail( "Exception expected." );
+ }
+ }
+ catch ( EnforcerRuleException e )
+ {
+ if ( !shouldFail )
+ {
+ fail( "No Exception expected:" + e.getLocalizedMessage() );
+ }
+ helper.getLog().debug( e.getMessage() );
+ }
+ }
+}
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestEnforcerRuleUtils.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestEnforcerRuleUtils.java
deleted file mode 100644
index 3583a6a..0000000
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestEnforcerRuleUtils.java
+++ /dev/null
@@ -1,263 +0,0 @@
-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.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.enforcer.EnforcerTestUtils;
-import org.apache.maven.plugins.enforcer.MockProject;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-/**
- * The Class TestEnforcerRuleUtils.
- *
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- */
-public class TestEnforcerRuleUtils
- extends AbstractMojoTestCase
-{
-
- /**
- * Test check if model matches.
- */
- public void testCheckIfModelMatches()
- {
-
- EnforcerRuleUtils utils = new EnforcerRuleUtils( EnforcerTestUtils.getHelper() );
-
- Model model = new Model();
- model.setArtifactId( "" );
- model.setGroupId( "" );
- model.setVersion( "" );
-
- // should generate internal NPE on the parent, but
- // will still
- // compare the raw values
- assertTrue( utils.checkIfModelMatches( "", "", "", model ) );
- assertFalse( utils.checkIfModelMatches( "", "", "1.0", model ) );
-
- // now setup a parent
- Parent parent = new Parent();
- parent.setArtifactId( "foo" );
- parent.setGroupId( "foo-group" );
- parent.setVersion( "1.0" );
- model.setParent( parent );
-
- // should NOT pickup the parent artifact
- assertFalse( utils.checkIfModelMatches( "foo-group", "foo", "1.0", model ) );
-
- // check that the version and group are inherited
- // from the parent.
- assertTrue( utils.checkIfModelMatches( "foo-group", "", "1.0", model ) );
-
- // check handling of nulls
- assertFalse( utils.checkIfModelMatches( "foo-group", null, "1.0", model ) );
- }
-
- /**
- * Test get models recursively bottom.
- *
- * @throws ArtifactResolutionException the artifact resolution exception
- * @throws ArtifactNotFoundException the artifact not found exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws XmlPullParserException the xml pull parser exception
- */
- public void testGetModelsRecursivelyBottom()
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- String path = "target/test-classes/requirePluginVersions/getPomRecursively/b/c";
-
- StringUtils.replace( path, "/", File.separator );
-
- File pom = new File( getBasedir() + File.separator + path, "pom.xml" );
-
- EnforcerRuleUtils utils = new EnforcerRuleUtils( EnforcerTestUtils.getHelper() );
- List models = utils.getModelsRecursively( "group", "c", "1.0", pom );
-
- // there should be 3
- assertEquals( 3, models.size() );
-
- // now make sure they are all there
- Model m = new Model();
- m.setGroupId( "group" );
- m.setVersion( "1.0" );
- m.setArtifactId( "c" );
-
- models.contains( m );
-
- m.setArtifactId( "b" );
- models.contains( m );
-
- m.setArtifactId( "a" );
- models.contains( m );
- }
-
- /**
- * Test get models recursively top.
- *
- * @throws ArtifactResolutionException the artifact resolution exception
- * @throws ArtifactNotFoundException the artifact not found exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws XmlPullParserException the xml pull parser exception
- */
- public void testGetModelsRecursivelyTop()
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- String path = "target/test-classes/requirePluginVersions/getPomRecursively";
-
- StringUtils.replace( path, "/", File.separator );
-
- File pom = new File( getBasedir() + File.separator + path, "pom.xml" );
-
- EnforcerRuleUtils utils = new EnforcerRuleUtils( EnforcerTestUtils.getHelper() );
-
- List models = utils.getModelsRecursively( "group", "a", "1.0", pom );
-
- // there should be 1
- assertEquals( 1, models.size() );
-
- // now make sure they are all there
- Model m = new Model();
- m.setGroupId( "group" );
- m.setVersion( "1.0" );
- m.setArtifactId( "a" );
-
- models.contains( m );
- }
-
- public void testGetModelsRecursivelyParentExpression()
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- String path = "target/test-classes/requirePluginVersions/parentExpression/child";
-
- StringUtils.replace( path, "/", File.separator );
-
- File pom = new File( getBasedir() + File.separator + path, "pom.xml" );
-
- // bit backwards - the project here should really be the one read in the first stage of getModelsRecursively
- MockProject parent = new MockProject();
- parent.setGroupId( "org.apache.maven.plugins.enforcer.test" );
- parent.setArtifactId( "parent" );
- parent.setVersion( "1.0-SNAPSHOT" );
-
- MockProject project = new MockProject();
- project.setParent( parent );
-
- EnforcerRuleUtils utils = new EnforcerRuleUtils( EnforcerTestUtils.getHelper( project ) );
-
- List models =
- utils.getModelsRecursively( "org.apache.maven.plugins.enforcer.test", "child", "1.0-SNAPSHOT", pom );
-
- // there should be 2
- assertEquals( 2, models.size() );
- }
-
- public void testGetModelsRecursivelyParentRelativePath()
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- String path = "target/test-classes/requirePluginVersions/parentRelativePath";
-
- StringUtils.replace( path, "/", File.separator );
-
- File pom = new File( getBasedir() + File.separator + path, "pom.xml" );
-
- // bit backwards - the project here should really be the one read in the first stage of getModelsRecursively
- MockProject parent = new MockProject();
- parent.setGroupId( "org.apache.maven.plugins.enforcer.test" );
- parent.setArtifactId( "parent" );
- parent.setVersion( "1.0-SNAPSHOT" );
-
- MockProject project = new MockProject();
- project.setParent( parent );
-
- EnforcerRuleUtils utils = new EnforcerRuleUtils( EnforcerTestUtils.getHelper( project ) );
-
- List models =
- utils.getModelsRecursively( "org.apache.maven.plugins.enforcer.test", "aggregate", "1.0-SNAPSHOT", pom );
-
- // there should be 2
- assertEquals( 2, models.size() );
- }
-
- public void testGetModelsRecursivelyParentRelativePathDirectory()
- throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
- {
- String path = "target/test-classes/requirePluginVersions/parentRelativePathDirectory";
-
- StringUtils.replace( path, "/", File.separator );
-
- File pom = new File( getBasedir() + File.separator + path, "pom.xml" );
-
- // bit backwards - the project here should really be the one read in the first stage of getModelsRecursively
- MockProject parent = new MockProject();
- parent.setGroupId( "org.apache.maven.plugins.enforcer.test" );
- parent.setArtifactId( "parent" );
- parent.setVersion( "1.0-SNAPSHOT" );
-
- MockProject project = new MockProject();
- project.setParent( parent );
-
- EnforcerRuleUtils utils = new EnforcerRuleUtils( EnforcerTestUtils.getHelper( project ) );
-
- List models =
- utils.getModelsRecursively( "org.apache.maven.plugins.enforcer.test", "aggregate", "1.0-SNAPSHOT", pom );
-
- // there should be 2
- assertEquals( 2, models.size() );
- }
-
- /**
- * Simpler wrapper to execute and deal with the expected result.
- *
- * @param rule the rule
- * @param helper the helper
- * @param shouldFail the should fail
- */
- public static void execute( EnforcerRule rule, EnforcerRuleHelper helper, boolean shouldFail )
- {
- try
- {
- rule.execute( helper );
- if ( shouldFail )
- {
- fail( "Exception expected." );
- }
- }
- catch ( EnforcerRuleException e )
- {
- if ( !shouldFail )
- {
- fail( "No Exception expected:" + e.getLocalizedMessage() );
- }
- helper.getLog().debug( e.getMessage() );
- }
- }
-}
diff --git a/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties b/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties
index a07d2f1..1b78093 100644
--- a/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties
+++ b/maven-enforcer-plugin/src/it/projects/require-plugin-versions-mm-ci-friendly/invoker.properties
@@ -14,4 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+invoker.maven.version = 3.5.0+
invoker.goals = install -Drevision=0.10.0-SNAPSHOT
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.