[ https://issues.apache.org/jira/browse/MENFORCER-473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17701112#comment-17701112 ]
Nils Christian Ehmke edited comment on MENFORCER-473 at 3/16/23 11:44 AM: -------------------------------------------------------------------------- Hi [~sjaranowski] , {quote} Can you more clarify your requirements, cases in this subject? {quote} Sure. We have rules evaluating expressions to get e.g. the resources folder of the Maven project: {code:java} protected Set<Path> getResourceFolders( final EnforcerRuleHelper helper ) throws EnforcerRuleException { ... final List<Resource> resources = ( List<Resource> ) helper.evaluate( "${project.build.resources}" ); {code} However, moving from Enforcer Plugin 3.0.0 to 3.2.1 a lot of the classes (e.g. the {_}EnforcerRuleHelper{_}) become deprecated, and classes for the evaluation are missing ("The type org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator cannot be resolved. It is indirectly referenced from required .class files"). The new way seems to simply inject _MavenProject_ to retrieve such properties, but this is not possible with Java 17. So how do we solve this? was (Author: nils): Hi [~sjaranowski] , > Can you more clarify your requirements, cases in this subject? Sure. We have rules evaluating expressions to get e.g. the resources folder of the Maven project: {code:java} protected Set<Path> getResourceFolders( final EnforcerRuleHelper helper ) throws EnforcerRuleException { ... final List<Resource> resources = ( List<Resource> ) helper.evaluate( "${project.build.resources}" ); {code} However, moving from Enforcer Plugin 3.0.0 to 3.2.1 a lot of the classes (e.g. the _EnforcerRuleHelper_) become deprecated, and classes for the evaluation are missing ("The type org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator cannot be resolved. It is indirectly referenced from required .class files"). The new way seems to simply inject _MavenProject_ to retrieve such properties, but this is not possible with Java 17. So how do we solve this? > Custom Rules are not processed with Java 17 > ------------------------------------------- > > Key: MENFORCER-473 > URL: https://issues.apache.org/jira/browse/MENFORCER-473 > Project: Maven Enforcer Plugin > Issue Type: Bug > Components: externalRules, Plugin, Rule API > Affects Versions: 3.2.1 > Environment: Windows, Java 17 > Reporter: Nils Christian Ehmke > Priority: Major > > Hi, > We noticed that our custom rule, using the newer API (as documented > [here)|https://maven.apache.org/enforcer/enforcer-api/writing-a-custom-rule.html] > is not processed using Java 17. > We created a sample project using the custom rule example. Once we use Java > 17 in the pom.xml it breaks. > {code:java} > <properties> > <api.version>3.2.1</api.version> > <maven.version>3.9.0</maven.version> > <!-- use JDK 1.8 at least --> > <maven.compiler.source>17</maven.compiler.source> > <maven.compiler.target>17</maven.compiler.target> > </properties> > ... > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-compiler-plugin</artifactId> > <version>3.11.0</version> > </plugin> > <plugin> > <!-- generate index of project components --> > <groupId>org.eclipse.sisu</groupId> > <artifactId>sisu-maven-plugin</artifactId> > <version>0.9.0.M1</version> > <executions> > <execution> > <goals> > <goal>main-index</goal> > </goals> > </execution> > </executions> > </plugin> > {code} > If we compile the custom rule and verify the using project, we get > {code} > [ERROR] Failed to execute goal > org.apache.maven.plugins:maven-enforcer-plugin:3.2.1:enforce (enforce) on > project maven-enforcer-plugin-sample-usage: Execution enforce of goal > org.apache.maven.plugins:maven-enforcer-plugin:3.2.1:enforce failed: Failed > to create enforcer rules with name: myCustomRule or for class: > org.apache.maven.plugins.enforcer.MyCustomRule -> [Help 1] > {code} > The index file itself looks good, so something else within the plugin or Sisu > Plexus seems to break. -- This message was sent by Atlassian Jira (v8.20.10#820010)