SLING-11862 Prevent usage of annotation dependencies with compile scope (#34)

diff --git a/sling-bundle-parent/pom.xml b/sling-bundle-parent/pom.xml
index a629fa0..6241b88 100644
--- a/sling-bundle-parent/pom.xml
+++ b/sling-bundle-parent/pom.xml
@@ -162,6 +162,17 @@
                                     </excludes>
                                     <message>Use the individual OSGi chapter dependencies instead of the aggregate ones. Further infos at http://docs.osgi.org/artifacts/#aggregate-artifacts.</message>
                                 </bannedDependencies>
+                                <bannedDependencies>
+                                    <searchTransitive>false</searchTransitive>
+                                    <excludes>
+                                        <exclude>org.osgi:org.osgi.annotation.versioning:*:*:compile</exclude>
+                                        <exclude>org.osgi:org.osgi.annotation.bundle:*:*:compile</exclude>
+                                        <exclude>org.osgi:org.osgi.service.component.annotations:*:*:compile</exclude>
+                                        <exclude>org.osgi:org.osgi.service.metatype.annotations:*:*:compile</exclude>
+                                        <exclude>org.apache.sling:org.apache.sling.servlets.annotations:*:*:compile</exclude>
+                                    </excludes>
+                                    <message>The annotation dependencies should be used with scope provided to prevent transitive inheritance and to prevent runtime inclusion</message>
+                                </bannedDependencies>
                             </rules>
                         </configuration>
                     </execution>
diff --git a/sling-parent/pom.xml b/sling-parent/pom.xml
index 7c950dd..a8bc4b8 100644
--- a/sling-parent/pom.xml
+++ b/sling-parent/pom.xml
@@ -147,6 +147,23 @@
                             </rules>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>enforce-scope-of-annotation-deps</id>
+                        <goals>
+                            <goal>enforce</goal>
+                        </goals>
+                        <configuration>
+                            <rules>
+                                <bannedDependencies>
+                                    <searchTransitive>false</searchTransitive>
+                                    <excludes>
+                                        <exclude>org.jetbrains:annotations:*:*:compile</exclude>
+                                    </excludes>
+                                    <message>The annotation dependencies should be used with scope provided to prevent transitive inheritance and to prevent runtime inclusion</message>
+                                </bannedDependencies>
+                            </rules>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
 
@@ -263,6 +280,10 @@
         <pluginManagement>
             <plugins>
                 <plugin>
+                    <artifactId>maven-enforcer-plugin</artifactId>
+                    <version>3.3.0</version>
+                </plugin>
+                <plugin>
                     <artifactId>maven-javadoc-plugin</artifactId>
                     <!-- this affects both direct invocation and execution in the context of site building (https://maven.apache.org/shared/maven-reporting-exec/) -->
                     <configuration>