Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bytecode version of multirelease metadata should be lower or equal to specified version #158

Merged
merged 1 commit into from Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,2 @@
invoker.goals = enforcer:enforce
invoker.buildResult = success
48 changes: 48 additions & 0 deletions src/it/enforce-bytecode-version-multirelease-2/pom.xml
@@ -0,0 +1,48 @@
<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>pim.pam.poum</groupId>
<artifactId>smoking</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>@enforcerPluginVersion@</version>
<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</dependency>
</dependencies>
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>1.8</maxJdkVersion>
</enforceBytecodeVersion>
</rules>
</configuration>
<executions>
<execution>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.13.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
9 changes: 9 additions & 0 deletions src/it/enforce-bytecode-version-multirelease-2/verify.groovy
@@ -0,0 +1,9 @@
File file = new File( basedir, "build.log" );
assert file.exists();

String text = file.getText("utf-8");

assert text.contains( '[INFO] Adding ignore: module-info' )
assert !text.contains( '[WARNING] Invalid bytecodeVersion for com.fasterxml.jackson.core:jackson-core:jar:2.13.0:runtime' )

return true;
Expand Up @@ -351,16 +351,16 @@ private String isBadArtifact( Artifact a )

if ( matcher.matches() )
{
Integer expectedMajor = JDK_TO_MAJOR_VERSION_NUMBER_MAPPING.get( matcher.group( 1 ) );
Integer maxExpectedMajor = JDK_TO_MAJOR_VERSION_NUMBER_MAPPING.get( matcher.group( 1 ) );

if (expectedMajor == null) {
if (maxExpectedMajor == null) {
getLog().warn( "Unknown bytecodeVersion for " + a + " : "
+ entry.getName() + ": got " + expectedMajor + " class-file-version" );
+ entry.getName() + ": got " + maxExpectedMajor + " class-file-version" );
}
else if ( major != expectedMajor )
else if ( major > maxExpectedMajor )
{
getLog().warn( "Invalid bytecodeVersion for " + a + " : "
+ entry.getName() + ": expected " + expectedMajor + ", but was " + major );
+ entry.getName() + ": expected lower or equal to " + maxExpectedMajor + ", but was " + major );
}
}
else
Expand Down