You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Karl Heinz Marbaise (JIRA)" <ji...@apache.org> on 2018/06/18 17:18:00 UTC
[jira] [Comment Edited] (MENFORCER-300) Enforcer somewhat is too
sensitive
[ https://issues.apache.org/jira/browse/MENFORCER-300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16516034#comment-16516034 ]
Karl Heinz Marbaise edited comment on MENFORCER-300 at 6/18/18 5:17 PM:
------------------------------------------------------------------------
I would recommend to use {{ignoreClasses}} configuration of {{EnforcerByteCodeVersion}}
see the docs:
https://www.mojohaus.org/extra-enforcer-rules/enforceBytecodeVersion.html
or for example like this:
{code:xml}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-bytecode-version</id>
<configuration>
<rules>
<!--
! Added the following ignores cause our target is JDK 7
! The given classes are JDK 8 compiled.
-->
<enforceBytecodeVersion>
<ignoreClasses>
<ignoreClass>com.thoughtworks.xstream.converters.reflection.LambdaConverter</ignoreClass>
<ignoreClass>com.thoughtworks.xstream.mapper.LambdaMapper</ignoreClass>
<ignoreClass>com.thoughtworks.xstream.converters.time.*</ignoreClass>
<ignoreClass>com.thoughtworks.xstream.core.util.ISO8601JavaTimeConverter</ignoreClass>
</ignoreClasses>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
{code}
or like this:
{code:xml}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-bytecode-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
<ignoreClasses>
<ignoreClass>module-info</ignoreClass>
</ignoreClasses>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
{code}
The other question related to this: What would you define as correctly handling {{module-info.class}} file?
was (Author: khmarbaise):
I would recommend to use {{ignoreClasses}} configuration of {{EnforcerByteCodeVersion}}
see the docs:
https://www.mojohaus.org/extra-enforcer-rules/enforceBytecodeVersion.html
or for example like this:
{code:xml}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-bytecode-version</id>
<configuration>
<rules>
<!--
! Added the following ignores cause our target is JDK 7
! The given classes are JDK 8 compiled.
-->
<enforceBytecodeVersion>
<ignoreClasses>
<ignoreClass>com.thoughtworks.xstream.converters.reflection.LambdaConverter</ignoreClass>
<ignoreClass>com.thoughtworks.xstream.mapper.LambdaMapper</ignoreClass>
<ignoreClass>com.thoughtworks.xstream.converters.time.*</ignoreClass>
<ignoreClass>com.thoughtworks.xstream.core.util.ISO8601JavaTimeConverter</ignoreClass>
</ignoreClasses>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
{code}
or like this:
{code:xml}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-bytecode-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
<ignoreClasses>
<ignoreClass>module-info</ignoreClass>
</ignoreClasses>
</enforceBytecodeVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
{code}
> Enforcer somewhat is too sensitive
> ----------------------------------
>
> Key: MENFORCER-300
> URL: https://issues.apache.org/jira/browse/MENFORCER-300
> Project: Maven Enforcer Plugin
> Issue Type: Bug
> Components: Plugin
> Affects Versions: 3.0.0-M1
> Reporter: Seweryn Habdank-Wojewodzki
> Priority: Major
>
> I am building library with maven settings:
> {code:java}
> <maven.compiler.source>1.7</maven.compiler.source>
> <maven.compiler.target>1.7</maven.compiler.target>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.7.0</version>
> <configuration>
> <executable>${jvm.path}/bin/javac</executable>
> <source>1.7</source>
> <target>1.7</target>
> </configuration>
> </plugin>
> {code}
> And our customer require that we provide JDK 1.7 compatible SW.
> Thanks to the help [How to confiugure maven-enforcer-plugin to exclude some rule in test scope?|https://stackoverflow.com/questions/49531075/how-to-confiugure-maven-enforcer-plugin-to-exclude-some-rule-in-test-scope/49534564#49534564] I had setup:
> {code:java}
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-enforcer-plugin</artifactId>
> <version>3.0.0-M1</version>
> <executions>
> <execution>
> <id>enforce-bytecode-version</id>
> <goals>
> <goal>enforce</goal>
> </goals>
> <configuration>
> <rules>
> <enforceBytecodeVersion>
> <maxJdkVersion>1.7</maxJdkVersion>
> <ignoredScopes>
> <ignoreScope>test</ignoreScope>
> </ignoredScopes>
> </enforceBytecodeVersion>
> </rules>
> <fail>true</fail>
> </configuration>
> </execution>
> </executions>
> <dependencies>
> <dependency>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>extra-enforcer-rules</artifactId>
> <version>1.0-beta-7</version>
> </dependency>
> </dependencies>
> </plugin>
> {code}
> Compiler plugin settings guarantee that **our** code is 1.7, but enforce plugin proves also dependencies.
> Our library is using Log4j2 v. 2.10.0 and apparently enforce plugin complains that:
> {code:java}
> log4j-api:jar:2.10.0:compile contains module-info.class targeted to JDK 1.9
> {code}
> Exactly I got:
> {code:java}
> [INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (enforce-bytecode-version) @ clj-log4j2-appender ---
> [INFO] Restricted to JDK 1.7 yet org.apache.logging.log4j:log4j-api:jar:2.10.0:compile contains module-info.class targeted to JDK 1.9
> [WARNING] Rule 0: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
> Found Banned Dependency: org.apache.logging.log4j:log4j-api:jar:2.10.0
> Use 'mvn dependency:tree' to locate the source of the banned dependencies.
> {code}
> However
> * our library is working very well on JDK 1.7 with given Log4j 2.10.0
> * dependency tree did not show this module-info, as it is single class and not a package
> Is then Enforcerer too sensitive? Handles Enforcerer correctly classes like module-info?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)