You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2021/10/14 07:57:47 UTC

[maven-plugin-tools] branch master updated: [MPLUGIN-370] Check that Maven dependencies are provided scope (#38)

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

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git


The following commit(s) were added to refs/heads/master by this push:
     new e40a388  [MPLUGIN-370] Check that Maven dependencies are provided scope (#38)
e40a388 is described below

commit e40a3880bb997ea7afb8fcc29f8cff81c69b99c8
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Thu Oct 14 09:57:44 2021 +0200

    [MPLUGIN-370] Check that Maven dependencies are provided scope (#38)
    
    This PR has two changes:
    * removed maven-artifact from maven-plugin-annotations (to not pull in
      whole artifact just for 6 constants, thay may also cause havoc if
      plugin developer does NOT declare maven-artifact with proper version)
    * generator mojo now yells if ANY of the core dependencies are not
      in provided scope.
---
 maven-plugin-annotations/pom.xml                   |  7 --
 .../maven/plugins/annotations/ResolutionScope.java | 15 ++--
 maven-plugin-plugin/pom.xml                        |  2 +
 .../invoker.properties                             | 18 +++++
 .../it/mplugin-370-maven-deps-scope-bad/pom.xml    | 94 ++++++++++++++++++++++
 .../org/apache/maven/plugin/coreit/FirstMojo.java  | 53 ++++++++++++
 .../mplugin-370-maven-deps-scope-bad/verify.groovy | 22 +++++
 .../invoker.properties                             | 18 +++++
 .../it/mplugin-370-maven-deps-scope-good/pom.xml   | 94 ++++++++++++++++++++++
 .../org/apache/maven/plugin/coreit/FirstMojo.java  | 53 ++++++++++++
 .../verify.groovy                                  | 22 +++++
 .../maven/plugin/plugin/AbstractGeneratorMojo.java | 47 ++++++++++-
 12 files changed, 427 insertions(+), 18 deletions(-)

diff --git a/maven-plugin-annotations/pom.xml b/maven-plugin-annotations/pom.xml
index 5ba9594..2969f33 100644
--- a/maven-plugin-annotations/pom.xml
+++ b/maven-plugin-annotations/pom.xml
@@ -31,11 +31,4 @@
   <name>Maven Plugin Tools Java Annotations</name>
   <description>Java annotations to use in Mojos</description>
 
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact</artifactId>
-      <version>3.0</version>
-    </dependency>
-  </dependencies>
 </project>
diff --git a/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/ResolutionScope.java b/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/ResolutionScope.java
index f8eaf61..e2bcd6a 100644
--- a/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/ResolutionScope.java
+++ b/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/ResolutionScope.java
@@ -19,12 +19,13 @@ package org.apache.maven.plugins.annotations;
  * under the License.
  */
 
-import org.apache.maven.artifact.Artifact;
-
 /**
  * Dependencies resolution scopes available before
  * <a href="/ref/current/maven-core/apidocs/org/apache/maven/lifecycle/internal/MojoExecutor.html">mojo execution</a>.
  *
+ * Important note: The {@code id} values of this enum correspond to constants of
+ * {@code org.apache.maven.artifact.Artifact} class and MUST BE KEPT IN SYNC.
+ *
  * @author Hervé Boutemy
  * @since 3.0
  */
@@ -38,28 +39,28 @@ public enum ResolutionScope
      * <code>compile</code> resolution scope
      * = <code>compile</code> + <code>system</code> + <code>provided</code> dependencies
      */
-    COMPILE( Artifact.SCOPE_COMPILE ),
+    COMPILE( "compile" ),
     /**
      * <code>compile+runtime</code> resolution scope (Maven 3 only)
      * = <code>compile</code> + <code>system</code> + <code>provided</code> + <code>runtime</code> dependencies
      */
-    COMPILE_PLUS_RUNTIME( Artifact.SCOPE_COMPILE_PLUS_RUNTIME ),
+    COMPILE_PLUS_RUNTIME( "compile+runtime" ),
     /**
      * <code>runtime</code> resolution scope
      * = <code>compile</code> + <code>runtime</code> dependencies
      */
-    RUNTIME( Artifact.SCOPE_RUNTIME ),
+    RUNTIME( "runtime" ),
     /**
      * <code>runtime+system</code> resolution scope (Maven 3 only)
      * = <code>compile</code> + <code>system</code> + <code>runtime</code> dependencies
      */
-    RUNTIME_PLUS_SYSTEM( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM ),
+    RUNTIME_PLUS_SYSTEM( "runtime+system" ),
     /**
      * <code>test</code> resolution scope
      * = <code>compile</code> + <code>system</code> + <code>provided</code> + <code>runtime</code> + <code>test</code>
      * dependencies
      */
-    TEST( Artifact.SCOPE_TEST );
+    TEST( "test" );
 
     private final String id;
 
diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 8b37b79..19ce510 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -47,10 +47,12 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-compat</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/invoker.properties b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/invoker.properties
new file mode 100644
index 0000000..c959b53
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/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.goals = process-classes
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/pom.xml b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/pom.xml
new file mode 100644
index 0000000..7514a0b
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/pom.xml
@@ -0,0 +1,94 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.maven-deps-scope-bad</groupId>
+  <artifactId>maven-deps-scope-bad</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>Maven Integration Test :: maven-deps-scope-bad</name>
+  <description>
+    Test plugin-plugin, which does not sets maven dependencies
+    to provided scope.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>@mavenVersion@</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>@project.version@</version>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.8.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+        </configuration>
+        <executions>
+          <execution>
+            <id>mojo-descriptor</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>help-goal</id>
+            <goals>
+              <goal>helpmojo</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
new file mode 100644
index 0000000..b8f7f62
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -0,0 +1,53 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Touches a test file.
+ *
+ * @since 1.2
+ */
+@Mojo( name = "first", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.INTEGRATION_TEST )
+public class FirstMojo
+    extends AbstractMojo
+{
+
+    /**
+     * @since 0.1
+     * @deprecated As of 0.2
+     */
+    @Parameter( alias = "alias" )
+    private String aliasedParam;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        // nothing
+    }
+}
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/verify.groovy b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/verify.groovy
new file mode 100644
index 0000000..50dfb65
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-bad/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.isFile()
+assert buildLog.text.contains( "Maven dependencies of Maven Plugins should be in provided scope." )
\ No newline at end of file
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/invoker.properties b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/invoker.properties
new file mode 100644
index 0000000..c959b53
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/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.goals = process-classes
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/pom.xml b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/pom.xml
new file mode 100644
index 0000000..a96154d
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/pom.xml
@@ -0,0 +1,94 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.maven-deps-scope-good</groupId>
+  <artifactId>maven-deps-scope-good</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>Maven Integration Test :: maven-deps-scope-good</name>
+  <description>
+    Test plugin-plugin, which does sets maven dependencies
+    to provided scope.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>@mavenVersion@</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>@project.version@</version>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.8.1</version>
+          <configuration>
+            <source>1.8</source>
+            <target>1.8</target>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+        </configuration>
+        <executions>
+          <execution>
+            <id>mojo-descriptor</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>help-goal</id>
+            <goals>
+              <goal>helpmojo</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
new file mode 100644
index 0000000..b8f7f62
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -0,0 +1,53 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Touches a test file.
+ *
+ * @since 1.2
+ */
+@Mojo( name = "first", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.INTEGRATION_TEST )
+public class FirstMojo
+    extends AbstractMojo
+{
+
+    /**
+     * @since 0.1
+     * @deprecated As of 0.2
+     */
+    @Parameter( alias = "alias" )
+    private String aliasedParam;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        // nothing
+    }
+}
diff --git a/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/verify.groovy b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/verify.groovy
new file mode 100644
index 0000000..cc8941c
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-370-maven-deps-scope-good/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.isFile()
+assert !buildLog.text.contains( "Maven dependencies of Maven Plugins should be in provided scope." )
\ No newline at end of file
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
index 203bac2..3a5aacc 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
@@ -198,10 +198,29 @@ public abstract class AbstractGeneratorMojo
             && project.getArtifactId().toLowerCase().endsWith( "-plugin" ) 
             && !"org.apache.maven.plugins".equals( project.getGroupId() ) )
         {
-            getLog().error( "\n\nArtifact Ids of the format maven-___-plugin are reserved for \n"
-                                + "plugins in the Group Id org.apache.maven.plugins\n"
-                                + "Please change your artifactId to the format ___-maven-plugin\n"
-                                + "In the future this error will break the build.\n\n" );
+            getLog().error( String.format( "%n%nArtifact Ids of the format maven-___-plugin are reserved for %n"
+                                + "plugins in the Group Id org.apache.maven.plugins%n"
+                                + "Please change your artifactId to the format ___-maven-plugin%n"
+                                + "In the future this error will break the build.%n%n" ) );
+        }
+
+        Set<Artifact> wrongScopedArtifacts = mavenDependenciesNotInProvidedScope();
+        if ( !wrongScopedArtifacts.isEmpty() )
+        {
+            StringBuilder errorMessage = new StringBuilder(
+                "%n%nMaven dependencies of Maven Plugins should be in provided scope.%n"
+                    + "Please make sure that all your dependencies declared in POM whose group ID is%n"
+                    + "org.apache.maven have set '<scope>provided</scope>' as well.%n"
+                    + "In the future this error will break the build.%n%n"
+                    + "The following dependencies are in wrong scope:%n"
+            );
+            for ( Artifact artifact : wrongScopedArtifacts )
+            {
+                errorMessage.append( " * " ).append( artifact ).append( "%n" );
+            }
+            errorMessage.append( "%nPlease fix your build!%n%n" );
+
+            getLog().error( String.format( errorMessage.toString() ) );
         }
 
         String defaultGoalPrefix = getDefaultGoalPrefix( project );
@@ -295,6 +314,26 @@ public abstract class AbstractGeneratorMojo
     }
 
     /**
+     * Collects all dependencies having {@code org.apache.maven} group ID that are NOT in provided scope.
+     */
+    private Set<Artifact> mavenDependenciesNotInProvidedScope()
+    {
+        LinkedHashSet<Artifact> wrongScopedDependencies = new LinkedHashSet<>();
+
+        for ( Artifact dependency : project.getArtifacts() )
+        {
+            if ( "org.apache.maven".equals( dependency.getGroupId() )
+                && dependency.getArtifactId().startsWith( "maven-" )
+                && !Artifact.SCOPE_PROVIDED.equals( dependency.getScope() ) )
+            {
+                wrongScopedDependencies.add( dependency );
+            }
+        }
+
+        return wrongScopedDependencies;
+    }
+
+    /**
      * Get dependencies filtered with mojoDependencies configuration.
      * 
      * @return eventually filtered dependencies, or even <code>null</code> if configured with empty mojoDependencies