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/05 23:39:52 UTC
[maven-enforcer] 01/01: [MENFORCER-268] Usage of CI friendly
version placeholders does not work o Changed the implementation to use the
Maven 3 based reading instead of hand made reading of pom files.
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch MENFORCER-268-ci-friendly
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git
commit 77830ccf45bf76d1a1ddbad31925cf7d048d74c9
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Mon Jan 1 12:20:19 2018 +0100
[MENFORCER-268] Usage of CI friendly version placeholders does not work
o Changed the implementation to use the Maven 3
based reading instead of hand made reading of pom files.
---
.../plugins/enforcer/RequireNoRepositories.java | 45 ++-
.../enforcer/TestRequireNoRepositories.java | 326 +++++++++++++--------
.../invoker.properties | 18 ++
.../pom.xml | 70 +++++
.../verify.groovy | 22 ++
.../invoker.properties | 18 ++
.../require-no-repositories-allow-repo/pom.xml | 70 +++++
.../verify.groovy | 22 ++
.../it/projects/require-no-repositories/pom.xml | 1 +
.../invoker.properties | 18 ++
.../pom.xml | 70 +++++
.../verify.groovy | 22 ++
.../invoker.properties | 18 ++
.../pom.xml | 114 +++----
.../verify.groovy | 22 ++
.../invoker.properties | 18 ++
.../pom.xml | 70 +++++
.../verify.groovy | 22 ++
.../child}/pom.xml | 34 +--
.../pom.xml | 5 +
20 files changed, 776 insertions(+), 229 deletions(-)
diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java
index cc5073d..9d7cbfc 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java
@@ -19,23 +19,19 @@ package org.apache.maven.plugins.enforcer;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
-import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtils;
+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.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/**
* This rule checks that this pom or its parents don't define a repository.
@@ -117,20 +113,29 @@ public class RequireNoRepositories
this.allowSnapshotPluginRepositories = allowSnapshotPluginRepositories;
}
+ private Log logger;
+
@Override
public void execute( EnforcerRuleHelper helper )
throws EnforcerRuleException
{
- EnforcerRuleUtils utils = new EnforcerRuleUtils( helper );
+ logger = helper.getLog();
- MavenProject project;
+ MavenSession session;
try
{
- project = (MavenProject) helper.evaluate( "${project}" );
+ session = (MavenSession) helper.evaluate( "${session}" );
+
+ List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects();
- List<Model> models =
- utils.getModelsRecursively( project.getGroupId(), project.getArtifactId(), project.getVersion(),
- new File( project.getBasedir(), "pom.xml" ) );
+ List<Model> models = new ArrayList<Model>();
+ for ( MavenProject mavenProject : sortedProjects )
+ {
+ logger.debug( "Scanning project: " + mavenProject.getGroupId() + ":" + mavenProject.getArtifactId()
+ + " version:" + mavenProject.getVersion() );
+ models.add( mavenProject.getOriginalModel() );
+ }
+
List<Model> badModels = new ArrayList<Model>();
StringBuffer newMsg = new StringBuffer();
@@ -190,22 +195,6 @@ public class RequireNoRepositories
{
throw new EnforcerRuleException( e.getLocalizedMessage() );
}
- catch ( ArtifactResolutionException e )
- {
- throw new EnforcerRuleException( e.getLocalizedMessage() );
- }
- catch ( ArtifactNotFoundException e )
- {
- throw new EnforcerRuleException( e.getLocalizedMessage() );
- }
- catch ( IOException e )
- {
- throw new EnforcerRuleException( e.getLocalizedMessage() );
- }
- catch ( XmlPullParserException e )
- {
- throw new EnforcerRuleException( e.getLocalizedMessage() );
- }
}
/**
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireNoRepositories.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireNoRepositories.java
index 9b6ac8b..c8b4cb7 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireNoRepositories.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireNoRepositories.java
@@ -1,5 +1,10 @@
package org.apache.maven.plugins.enforcer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -20,236 +25,321 @@ package org.apache.maven.plugins.enforcer;
*/
import java.util.Collections;
+import java.util.List;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.RepositoryPolicy;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.junit.Before;
+import org.junit.Test;
/**
* Test the "require no repositories" rule.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @author <a href="mailto:khmarbaise@apache.org">Karl Heinz Marbaise</a>
*/
public class TestRequireNoRepositories
- extends PlexusTestCase
{
private EnforcerRuleHelper helper;
private RequireNoRepositories rule;
- private MockProject project;
+ private MavenSession session;
- public void setUp()
- throws Exception
+ @Before
+ public void before()
+ throws ExpressionEvaluationException
{
- super.setUp();
+ session = mock( MavenSession.class );
+ helper = mock( EnforcerRuleHelper.class );
+
+ when( helper.evaluate( "${session}" ) ).thenReturn( session );
+
+ Log log = mock( Log.class );
+ when( helper.getLog() ).thenReturn( log );
rule = new RequireNoRepositories();
rule.setMessage( "my message" );
+ }
- project = new MockProject();
- project.setGroupId( "org.apache.maven.plugins.enforcer.test" );
- project.setVersion( "1.0-SNAPSHOT" );
+ private MavenProject createMavenProject()
+ {
+ MavenProject mp = mock( MavenProject.class );
+ when( mp.getGroupId() ).thenReturn( "org.apache.maven.plugins.enforcer.test" );
+ when( mp.getArtifactId() ).thenReturn( "no-repositories-child" );
+ when( mp.getVersion() ).thenReturn( "1.0-SNAPSHOT" );
- helper = EnforcerTestUtils.getHelper( project );
+ return mp;
}
- public void testAllBannedNoRepositories()
- throws EnforcerRuleException
+ private Model createOriginalModel()
{
- project.setArtifactId( "no-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/no-repositories/child" ) );
+ Model m = mock( Model.class );
+ when( m.getGroupId() ).thenReturn( "org.apache.maven.plugins.enforcer.test" );
+ when( m.getArtifactId() ).thenReturn( "no-repositories" );
+ when( m.getVersion() ).thenReturn( "1.0-SNAPSHOT" );
+ return m;
+ }
- rule.execute( helper );
+ private MavenProject createStandAloneProject()
+ {
+ MavenProject mp = createMavenProject();
+ Model originalModel = createOriginalModel();
+ // This means the interpolated model is the same
+ // as the non interpolated.
+ when( mp.getModel() ).thenReturn( originalModel );
+ when( mp.getOriginalModel() ).thenReturn( originalModel );
+ return mp;
}
- public void testAllBannedWithRepositories()
- throws EnforcerRuleException
+ private void setupSortedProjects( List<MavenProject> projectList )
{
- project.setArtifactId( "with-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/with-repositories/child" ) );
+ ProjectDependencyGraph pdg = mock( ProjectDependencyGraph.class );
+ when( session.getProjectDependencyGraph() ).thenReturn( pdg );
+ when( pdg.getSortedProjects() ).thenReturn( projectList );
+ }
- try
- {
- rule.execute( helper );
- fail( "Should have exception" );
- }
- catch ( EnforcerRuleException e )
- {
- assertTrue( true );
- }
+ private Repository createRepository( String id, String url )
+ {
+ Repository r = new Repository();
+ r.setId( id );
+ r.setUrl( url );
+ RepositoryPolicy snapshotPolicy = new RepositoryPolicy();
+ snapshotPolicy.setEnabled( false );
+ snapshotPolicy.setUpdatePolicy( "daily" );
+ r.setSnapshots( snapshotPolicy );
+
+ RepositoryPolicy releasePolicy = new RepositoryPolicy();
+ releasePolicy.setEnabled( true );
+ releasePolicy.setUpdatePolicy( "never" );
+ r.setReleases( releasePolicy );
+
+ return r;
}
- public void testAllBannedWithAllowedRepositories()
- throws EnforcerRuleException
+ private Repository createSnapshotRepository( String id, String url )
{
- rule.setAllowedRepositories( Collections.singletonList( "repo" ) );
+ Repository r = new Repository();
+ r.setId( id );
+ r.setUrl( url );
- project.setArtifactId( "with-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/with-repositories/child" ) );
+ RepositoryPolicy snapshotPolicy = new RepositoryPolicy();
+ snapshotPolicy.setEnabled( true );
+ snapshotPolicy.setUpdatePolicy( "daily" );
+ r.setSnapshots( snapshotPolicy );
- rule.execute( helper );
+ RepositoryPolicy releasePolicy = new RepositoryPolicy();
+ releasePolicy.setEnabled( false );
+ r.setReleases( releasePolicy );
+
+ return r;
}
- public void testAllBannedWithAllowedPluginRepositories()
+ private MavenProject addRepository( MavenProject project, Repository r )
+ {
+ Model originalModel = project.getOriginalModel();
+ List<Repository> repositories = new ArrayList<Repository>();
+ repositories.add( r );
+ when( originalModel.getRepositories() ).thenReturn( repositories );
+ return project;
+ }
+
+ private MavenProject addPluginRepository( MavenProject project, Repository r )
+ {
+ Model originalModel = project.getOriginalModel();
+ List<Repository> repositories = new ArrayList<Repository>();
+ repositories.add( r );
+ when( originalModel.getPluginRepositories() ).thenReturn( repositories );
+ return project;
+ }
+
+ /**
+ * This model contains a single module maven project without any repository.
+ */
+ @Test
+ public void testAllBannedNoRepositories()
throws EnforcerRuleException
{
- rule.setAllowedPluginRepositories( Collections.singletonList( "repo" ) );
+ MavenProject baseProject = createStandAloneProject();
+ setupSortedProjects( Collections.singletonList( baseProject ) );
+
+ rule.execute( helper );
+ }
- project.setArtifactId( "with-plugin-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/with-plugin-repositories/child" ) );
+ /**
+ * The model contains a single repository which is is not allowed by the default rules.
+ */
+ @Test( expected = EnforcerRuleException.class )
+ public void testAllBannedWithRepository()
+ throws EnforcerRuleException
+ {
+ MavenProject baseProject = createStandAloneProject();
+ addRepository( baseProject, createRepository( "repo", "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
rule.execute( helper );
}
- public void testReposNotBannedNoRepositories()
+ /**
+ * The model contains a single repository which is allowed by setting allowedRepositories to the id.
+ */
+ @Test
+ public void testAllBannedWithAllowedRepositories()
throws EnforcerRuleException
{
- rule.setBanRepositories( false );
+ final String repositoryId = "repo";
+ rule.setAllowedRepositories( Collections.singletonList( repositoryId ) );
- project.setArtifactId( "no-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/no-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ addRepository( baseProject, createRepository( repositoryId, "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
rule.execute( helper );
}
- public void testReposNotBannedWithRepositories()
+ /**
+ * The model contains a single repository. Turned off ban repositories.
+ */
+ @Test
+ public void testRepositoriesNotBannedWithSingleRepository()
throws EnforcerRuleException
{
+ final String repositoryId = "repo";
+
rule.setBanRepositories( false );
- project.setArtifactId( "with-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/with-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ addRepository( baseProject, createRepository( repositoryId, "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
rule.execute( helper );
}
- public void testReposNotBannedWithPluginRepositories()
+ /**
+ * The model contains no repository at all. Turned off ban repositories.
+ */
+ @Test
+ public void testRepositoriesNotBannedWithOutAnyRepository()
throws EnforcerRuleException
{
rule.setBanRepositories( false );
- project.setArtifactId( "with-plugin-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/with-plugin-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ setupSortedProjects( Collections.singletonList( baseProject ) );
- try
- {
- rule.execute( helper );
- fail( "Should have exception" );
- }
- catch ( EnforcerRuleException e )
- {
- assertTrue( true );
- }
+ rule.execute( helper );
}
- public void testPluginReposNotBannedNoRepositories()
+ /**
+ * This model contains a single plugin repository. The given plugin repository is added to the list of allowed
+ * plugin repositories.
+ */
+ @Test
+ public void testAllBannedWithAllowedPluginRepositories()
throws EnforcerRuleException
{
- rule.setBanPluginRepositories( false );
+ final String repositoryId = "repo";
+ rule.setAllowedPluginRepositories( Collections.singletonList( repositoryId ) );
- project.setArtifactId( "no-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/no-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ addPluginRepository( baseProject, createRepository( repositoryId, "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
rule.execute( helper );
}
- public void testPluginReposNotBannedWithRepositories()
+ /**
+ * The model contains a single plugin repository. Turned off ban plugin repositories.
+ */
+ @Test
+ public void testPluginRepositoriesNotBannedWithSinglePluginRepository()
throws EnforcerRuleException
{
+ final String repositoryId = "repo";
+
rule.setBanPluginRepositories( false );
- project.setArtifactId( "with-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/with-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ addPluginRepository( baseProject, createRepository( repositoryId, "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
- try
- {
- rule.execute( helper );
- fail( "Should have exception" );
- }
- catch ( EnforcerRuleException e )
- {
- assertTrue( true );
- }
+ rule.execute( helper );
}
- public void testPluginReposNotBannedWithPluginRepositories()
+ /**
+ * The model contains no repository at all. Turned off ban plugin repositories.
+ */
+ @Test
+ public void testPluginRepositoriesNotBannedWithOutAnyRepository()
throws EnforcerRuleException
{
rule.setBanPluginRepositories( false );
- project.setArtifactId( "with-plugin-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/with-plugin-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ setupSortedProjects( Collections.singletonList( baseProject ) );
rule.execute( helper );
}
- public void testReposNotAllowedWithSnapshotRepositories()
+ @Test( expected = EnforcerRuleException.class )
+ public void testAllBannedWithSnapshotRepository()
throws EnforcerRuleException
{
- rule.setAllowSnapshotRepositories( true );
+ MavenProject baseProject = createStandAloneProject();
+ addRepository( baseProject, createSnapshotRepository( "repo", "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
- project.setArtifactId( "snapshot-plugin-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/snapshot-plugin-repositories/child" ) );
-
- try
- {
- rule.execute( helper );
- fail( "Should have exception" );
- }
- catch ( EnforcerRuleException e )
- {
- assertTrue( true );
- }
+ rule.execute( helper );
}
- public void testReposAllowedWithSnapshotRepositories()
+ @Test
+ public void testAllBannedWithSnapshotRepositoryAllowedRepositories()
throws EnforcerRuleException
{
- rule.setAllowSnapshotRepositories( true );
+ final String repositoryId = "repo";
+ rule.setAllowedRepositories( Collections.singletonList( repositoryId ) );
- project.setArtifactId( "snapshot-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/snapshot-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ addRepository( baseProject, createSnapshotRepository( repositoryId, "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
rule.execute( helper );
}
- public void testPluginReposNotAllowedWithSnapshotRepositories()
+ @Test
+ public void testAllBannedWithSnapshotRepositoryAndSetAllowSnapshotRepositories()
throws EnforcerRuleException
{
- rule.setAllowSnapshotPluginRepositories( true );
+ final String repositoryId = "repo";
+ rule.setAllowSnapshotRepositories( true );
- project.setArtifactId( "snapshot-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/snapshot-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ addRepository( baseProject, createSnapshotRepository( repositoryId, "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
- try
- {
- rule.execute( helper );
- fail( "Should have exception" );
- }
- catch ( EnforcerRuleException e )
- {
- assertTrue( true );
- }
+ rule.execute( helper );
}
- public void testPluginReposAllowedWithSnapshotPluginRepositories()
+ @Test
+ public void testAllBannedWithSnapshotPluginRepositoryAndSetAllowSnapshotPluginRepositories()
throws EnforcerRuleException
{
+ final String repositoryId = "repo";
rule.setAllowSnapshotPluginRepositories( true );
- project.setArtifactId( "snapshot-plugin-repositories-child" );
- project.setBaseDir( getTestFile( "target/test-classes/requireNoRepositories/snapshot-plugin-repositories/child" ) );
+ MavenProject baseProject = createStandAloneProject();
+ addPluginRepository( baseProject, createSnapshotRepository( repositoryId, "http://example.com/repo" ) );
+ setupSortedProjects( Collections.singletonList( baseProject ) );
rule.execute( helper );
}
- /**
- * Test id.
- */
- public void testId()
- {
- RequireNoRepositories rule = new RequireNoRepositories();
- rule.getCacheId();
- }
}
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/invoker.properties b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/invoker.properties
new file mode 100644
index 0000000..c98ac4c
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.buildResult=failure
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/pom.xml
new file mode 100644
index 0000000..ba8a6a7
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+
+ <description>This IT makes sure to prevent having pluginRepositories inside the pom.</description>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>plugin-repo</id>
+ <url>http://example.com/repo</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <repositories>
+ <repository>
+ <id>com.asual.maven.public</id>
+ <name>Asual Public Repository</name>
+ <url>http://localhost</url>
+ </repository>
+ </repositories>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireNoRepositories>
+ <allowedPluginRepositories>plugin-repo</allowedPluginRepositories>
+ </requireNoRepositories>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/verify.groovy b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/verify.groovy
new file mode 100644
index 0000000..c065765
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-plugin-repo/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.text.contains( '[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireNoRepositories failed with message:' )
+assert buildLog.text.contains( 'Some poms have repositories defined:' )
+assert buildLog.text.contains( 'org.apache.maven.its.enforcer:test version:1.0 has repositories [com.asual.maven.public]' )
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/invoker.properties b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/invoker.properties
new file mode 100644
index 0000000..c98ac4c
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.buildResult=failure
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/pom.xml
new file mode 100644
index 0000000..c0af0cc
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+
+ <description>This IT makes sure to prevent having pluginRepositories inside the pom.</description>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>plugin-repo</id>
+ <url>http://example.com/repo</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <repositories>
+ <repository>
+ <id>com.asual.maven.public</id>
+ <name>Asual Public Repository</name>
+ <url>http://localhost</url>
+ </repository>
+ </repositories>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireNoRepositories>
+ <allowedRepositories>com.asual.maven.public</allowedRepositories>
+ </requireNoRepositories>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/verify.groovy b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/verify.groovy
new file mode 100644
index 0000000..b9538f3
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories-allow-repo/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.text.contains( '[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireNoRepositories failed with message:' )
+assert buildLog.text.contains( 'Some poms have repositories defined:' )
+assert buildLog.text.contains( 'org.apache.maven.its.enforcer:test version:1.0 has plugin repositories [plugin-repo]' )
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
index c66de18..bf5d7f9 100644
--- a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
@@ -27,6 +27,7 @@ under the License.
<version>1.0</version>
<description>
+ This IT demonstrates having no repositories defined at all.
</description>
<build>
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/invoker.properties b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/invoker.properties
new file mode 100644
index 0000000..c98ac4c
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.buildResult=failure
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/pom.xml
new file mode 100644
index 0000000..4951265
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+
+ <description>This IT makes sure to prevent having defined pluginRepository and repository in allowedPluginRepositories</description>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>plugin-repo</id>
+ <url>http://example.com/repo</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <repositories>
+ <repository>
+ <id>com.asual.maven.public</id>
+ <name>Asual Public Repository</name>
+ <url>http://localhost</url>
+ </repository>
+ </repositories>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireNoRepositories>
+ <allowedPluginRepositories>plugin-repo,com.asual.maven.public</allowedPluginRepositories>
+ </requireNoRepositories>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/verify.groovy b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/verify.groovy
new file mode 100644
index 0000000..c065765
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_allowed-plugin-repo/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.text.contains( '[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireNoRepositories failed with message:' )
+assert buildLog.text.contains( 'Some poms have repositories defined:' )
+assert buildLog.text.contains( 'org.apache.maven.its.enforcer:test version:1.0 has repositories [com.asual.maven.public]' )
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/invoker.properties b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/invoker.properties
new file mode 100644
index 0000000..c98ac4c
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.buildResult=failure
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/pom.xml
similarity index 88%
copy from maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
copy to maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/pom.xml
index c66de18..0ceb88b 100644
--- a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/pom.xml
@@ -1,55 +1,59 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-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.
--->
-
-<project>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.maven.its.enforcer</groupId>
- <artifactId>test</artifactId>
- <version>1.0</version>
-
- <description>
- </description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>@project.version@</version>
- <executions>
- <execution>
- <id>test</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireNoRepositories>
- </requireNoRepositories>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>repo</id>
+ <url>http://example.com/repo</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireNoRepositories>
+ </requireNoRepositories>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/verify.groovy b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/verify.groovy
new file mode 100644
index 0000000..b3c2b46
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_plugin-repositories/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.text.contains( '[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireNoRepositories failed with message:' )
+assert buildLog.text.contains( 'Some poms have repositories defined:' )
+assert buildLog.text.contains( 'org.apache.maven.its.enforcer:test version:1.0 has plugin repositories [repo]' )
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/invoker.properties b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/invoker.properties
new file mode 100644
index 0000000..c98ac4c
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.buildResult=failure
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/pom.xml
new file mode 100644
index 0000000..ba8a6a7
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+
+ <description>This IT makes sure to prevent having pluginRepositories inside the pom.</description>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>plugin-repo</id>
+ <url>http://example.com/repo</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <repositories>
+ <repository>
+ <id>com.asual.maven.public</id>
+ <name>Asual Public Repository</name>
+ <url>http://localhost</url>
+ </repository>
+ </repositories>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireNoRepositories>
+ <allowedPluginRepositories>plugin-repo</allowedPluginRepositories>
+ </requireNoRepositories>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/verify.groovy b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/verify.groovy
new file mode 100644
index 0000000..c065765
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure_repositories/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.text.contains( '[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireNoRepositories failed with message:' )
+assert buildLog.text.contains( 'Some poms have repositories defined:' )
+assert buildLog.text.contains( 'org.apache.maven.its.enforcer:test version:1.0 has repositories [com.asual.maven.public]' )
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories_mm/child/pom.xml
similarity index 53%
copy from maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
copy to maven-enforcer-plugin/src/it/projects/require-no-repositories_mm/child/pom.xml
index c66de18..b9c3410 100644
--- a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_mm/child/pom.xml
@@ -22,34 +22,12 @@ under the License.
<project>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.maven.its.enforcer</groupId>
- <artifactId>test</artifactId>
- <version>1.0</version>
+ <parent>
+ <groupId>org.apache.maven.its.enforcer</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+ </parent>
- <description>
- </description>
+ <artifactId>child</artifactId>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>@project.version@</version>
- <executions>
- <execution>
- <id>test</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireNoRepositories>
- </requireNoRepositories>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml b/maven-enforcer-plugin/src/it/projects/require-no-repositories_mm/pom.xml
similarity index 91%
copy from maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
copy to maven-enforcer-plugin/src/it/projects/require-no-repositories_mm/pom.xml
index c66de18..e2651ac 100644
--- a/maven-enforcer-plugin/src/it/projects/require-no-repositories/pom.xml
+++ b/maven-enforcer-plugin/src/it/projects/require-no-repositories_mm/pom.xml
@@ -25,8 +25,13 @@ under the License.
<groupId>org.apache.maven.its.enforcer</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>child</module>
+ </modules>
<description>
+ This IT demonstrates having no repositories defined at all.
</description>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.