You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2023/01/01 17:21:18 UTC

[GitHub] [maven-enforcer] kwin commented on a diff in pull request #216: [MENFORCER-455] New Enforcer API

kwin commented on code in PR #216:
URL: https://github.com/apache/maven-enforcer/pull/216#discussion_r1059777291


##########
enforcer-api/src/site/apt/writing-a-custom-rule.apt.vm:
##########
@@ -29,57 +29,24 @@ Writing a custom rule
   {{{http://maven.apache.org/plugins/maven-enforcer-plugin/}maven-enforcer-plugin}}. 
   
   Note: The files shown below may be downloaded here: {{{./custom-rule.zip}custom-rule.zip}}
+
+* Project with custom Enforcer Rule
+
+  First make a new jar project starting with the sample pom below:
   
-  [[1]] First make a new jar project starting with the sample pom below:
-  
-+---+
-<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>custom-rule</groupId>
-  <artifactId>custom-rule-sample</artifactId>
-  <packaging>jar</packaging>
-  <version>1.0</version>
-  <name>My Custom Rule</name>
-  <description>This is my custom rule.</description>
-  <properties>
-    <api.version>${project.version}</api.version>
-    <maven.version>${mavenPrerequisite}</maven.version>
-  </properties>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven.enforcer</groupId>
-      <artifactId>enforcer-api</artifactId>
-      <version>${api.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-core</artifactId>
-      <version>${maven.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>${maven.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-  <build>
-  </build>
-</project>
-+---+
-  Note that the classloader is shared with the embedding <<<maven-enforcer-plugin>>> (a regular {{{https://maven.apache.org/guides/mini/guide-maven-classloading.html#Plugin_Classloaders}plugin classloader}}) 
-  and therefore the artifacts <<<org.apache.maven.enforcer:enforcer-api>>> and <<<org.apache.maven.enforcer:enforcer-rules>>> are always loaded in the same version as the embedding <<<maven-enforcer-plugin>>>.
-  Custom rule artifacts should therefore only depend on `enforcer-api` and core Maven artifacts with <<<provided>>> scope (for details refer to {{{https://issues.apache.org/jira/browse/MNG-7097}MNG-7097}}).
-  The classes available from `enforcer-rules` must not be used from custom rules, as those are not considered API and may change in backwards-incompatible ways with every `maven-enforcer` version (even minor ones).
-  
+%{snippet|id=project-pom|file=target/custom-rule-sample/pom.xml}
+
+  Note that the classloader is shared with the embedding <<<maven-enforcer-plugin>>> (a regular {{{https://maven.apache.org/guides/mini/guide-maven-classloading.html#Plugin_Classloaders}plugin classloader}})
+  and therefore the artifacts <<<org.apache.maven.enforcer:enforcer-api>>> are always loaded in the same version as the embedding <<<maven-enforcer-plugin>>>.
+
+  Custom rule artifacts should therefore only depend on <<<enforcer-api>>> and core Maven artifacts with <<<provided>>> scope (for details refer to {{{https://issues.apache.org/jira/browse/MNG-7097}MNG-7097}}).
+
+  The classes available from <<<enforcer-rules>>> must not be used from custom rules, as those are not considered API and may change in backwards-incompatible ways with every <<<maven-enforcer>>> version (even minor ones).
+
+  Another dependencies used by custom rule should be in compile scope.

Review Comment:
   ```suggestion
     Other dependencies used by custom rule at run time should have `compile` scope.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org